-
-
+ {type === "version-update" &&
+ progress &&
+ "current_browser" in progress && (
+
+
+ {progress.current_browser && (
+ <>Looking for updates for {progress.current_browser}>
+ )}
+
+
+
+
+ {progress.current}/{progress.total}
+
-
- {progress.current}/{progress.total}
-
-
- )}
+ )}
{/* Twilight update progress */}
{type === "twilight-update" && (
diff --git a/src/components/settings-dialog.tsx b/src/components/settings-dialog.tsx
index dad9346..68d311f 100644
--- a/src/components/settings-dialog.tsx
+++ b/src/components/settings-dialog.tsx
@@ -21,7 +21,7 @@ import {
} from "@/components/ui/select";
import { usePermissions } from "@/hooks/use-permissions";
import type { PermissionType } from "@/hooks/use-permissions";
-import { showSuccessToast } from "@/lib/toast-utils";
+import { showErrorToast, showSuccessToast } from "@/lib/toast-utils";
import { invoke } from "@tauri-apps/api/core";
import { useTheme } from "next-themes";
import { useCallback, useEffect, useState } from "react";
@@ -210,11 +210,16 @@ export function SettingsDialog({ isOpen, onClose }: SettingsDialogProps) {
await invoke("clear_all_version_cache_and_refetch");
showSuccessToast("Cache cleared successfully", {
description:
- "All browser version cache has been cleared and browsers are being refreshed",
+ "All browser version cache has been cleared and browsers are being refreshed.",
duration: 4000,
});
} catch (error) {
console.error("Failed to clear cache:", error);
+ showErrorToast("Failed to clear cache", {
+ description:
+ error instanceof Error ? error.message : "Unknown error occurred",
+ duration: 4000,
+ });
} finally {
setIsClearingCache(false);
}
@@ -237,9 +242,9 @@ export function SettingsDialog({ isOpen, onClose }: SettingsDialogProps) {
const getPermissionIcon = (type: PermissionType) => {
switch (type) {
case "microphone":
- return
;
+ return
;
case "camera":
- return
;
+ return
;
}
};
@@ -255,7 +260,7 @@ export function SettingsDialog({ isOpen, onClose }: SettingsDialogProps) {
const getStatusBadge = (isGranted: boolean) => {
if (isGranted) {
return (
-
+
Granted
);
@@ -436,7 +441,7 @@ export function SettingsDialog({ isOpen, onClose }: SettingsDialogProps) {
{permissions.map((permission) => (
{getPermissionIcon(permission.permission_type)}
diff --git a/src/components/version-update-settings.tsx b/src/components/version-update-settings.tsx
index 7f2cea5..0bbf250 100644
--- a/src/components/version-update-settings.tsx
+++ b/src/components/version-update-settings.tsx
@@ -31,8 +31,8 @@ export function VersionUpdateSettings() {
return (
-
-
+
+
Background Version Updates
@@ -44,8 +44,8 @@ export function VersionUpdateSettings() {
{/* Current Status */}
-
-
+
+
Last Update
@@ -54,8 +54,8 @@ export function VersionUpdateSettings() {
-
-
+
+
Next Update
@@ -69,16 +69,14 @@ export function VersionUpdateSettings() {
{/* Progress indicator */}
{isUpdating && updateProgress && (
-
+
Updating Browser Versions
{updateProgress.current_browser ? (
<>
- Checking {updateProgress.current_browser} (
+ Looking for updates for {updateProgress.current_browser} (
{updateProgress.completed_browsers}/
{updateProgress.total_browsers})
-
- {updateProgress.new_versions_found} new versions found so far
>
) : (
"Starting version update..."
@@ -88,7 +86,7 @@ export function VersionUpdateSettings() {
)}
{/* Manual update button */}
-
+
Manual Update
@@ -104,14 +102,14 @@ export function VersionUpdateSettings() {
size="sm"
disabled={isUpdating}
>
-
+
{isUpdating ? "Updating..." : "Check Now"}
{/* Information about background updates */}
-
+
How it works
• Version information is checked automatically every 3 hours
diff --git a/src/hooks/use-browser-download.ts b/src/hooks/use-browser-download.ts
index 9bc5fd9..f0f70f8 100644
--- a/src/hooks/use-browser-download.ts
+++ b/src/hooks/use-browser-download.ts
@@ -5,11 +5,11 @@ import {
showErrorToast,
showFetchingToast,
showSuccessToast,
+ showUnifiedVersionUpdateToast,
} from "@/lib/toast-utils";
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { useCallback, useEffect, useState } from "react";
-import { toast } from "sonner";
interface GithubRelease {
tag_name: string;
@@ -137,31 +137,50 @@ export function useBrowserDownload() {
if (progress.status === "updating") {
setIsUpdatingVersions(true);
- if (progress.current_browser) {
- const browserName = getBrowserDisplayName(progress.current_browser);
- showFetchingToast(browserName, {
- id: `version-update-${progress.current_browser}`,
- description: "Fetching latest release information...",
- });
- }
+
+ // Show unified progress toast
+ const currentBrowserName = progress.current_browser
+ ? getBrowserDisplayName(progress.current_browser)
+ : undefined;
+
+ showUnifiedVersionUpdateToast("Checking for browser updates...", {
+ description: currentBrowserName
+ ? `Fetching ${currentBrowserName} release information...`
+ : "Initializing version check...",
+ progress: {
+ current: progress.completed_browsers,
+ total: progress.total_browsers,
+ found: progress.new_versions_found,
+ current_browser: currentBrowserName,
+ },
+ });
} else if (progress.status === "completed") {
setIsUpdatingVersions(false);
+ dismissToast("unified-version-update");
+
if (progress.new_versions_found > 0) {
showSuccessToast(
`Found ${progress.new_versions_found} new browser versions!`,
{
- duration: 3000,
+ duration: 4000,
+ description:
+ "Version information has been updated in the background",
},
);
+ } else {
+ showSuccessToast("No new browser versions found", {
+ duration: 3000,
+ description: "All browser versions are up to date",
+ });
}
- // Dismiss any update toasts
- toast.dismiss();
} else if (progress.status === "error") {
setIsUpdatingVersions(false);
+ dismissToast("unified-version-update");
+
showErrorToast("Failed to check for new versions", {
duration: 4000,
+ description: "Check your internet connection and try again",
});
- toast.dismiss();
}
},
);
diff --git a/src/hooks/use-version-updater.ts b/src/hooks/use-version-updater.ts
index 1a184ba..6c50810 100644
--- a/src/hooks/use-version-updater.ts
+++ b/src/hooks/use-version-updater.ts
@@ -1,5 +1,5 @@
import { getBrowserDisplayName } from "@/lib/browser-utils";
-import { showLoadingToast, showVersionUpdateToast } from "@/lib/toast-utils";
+import { dismissToast, showUnifiedVersionUpdateToast } from "@/lib/toast-utils";
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { useCallback, useEffect, useState } from "react";
@@ -46,34 +46,31 @@ export function useVersionUpdater() {
if (progress.status === "updating") {
setIsUpdating(true);
- if (progress.current_browser) {
- const browserName = getBrowserDisplayName(progress.current_browser);
- showVersionUpdateToast(
- `Downloading release information for ${browserName}`,
- {
- id: "version-update-progress",
- progress: {
- current: progress.completed_browsers + 1,
- total: progress.total_browsers,
- found: progress.new_versions_found,
- },
- },
- );
- } else {
- showLoadingToast("Starting version update check...", {
- id: "version-update-progress",
- description: "Initializing browser version check...",
- });
- }
+ // Show unified progress toast
+ const currentBrowserName = progress.current_browser
+ ? getBrowserDisplayName(progress.current_browser)
+ : undefined;
+
+ showUnifiedVersionUpdateToast("Checking for browser updates...", {
+ description: currentBrowserName
+ ? `Fetching ${currentBrowserName} release information...`
+ : "Initializing version check...",
+ progress: {
+ current: progress.completed_browsers,
+ total: progress.total_browsers,
+ found: progress.new_versions_found,
+ current_browser: currentBrowserName,
+ },
+ });
} else if (progress.status === "completed") {
setIsUpdating(false);
setUpdateProgress(null);
+ dismissToast("unified-version-update");
if (progress.new_versions_found > 0) {
toast.success(
`Found ${progress.new_versions_found} new browser versions!`,
{
- id: "version-update-progress",
duration: 4000,
description:
"Version information has been updated in the background",
@@ -81,7 +78,6 @@ export function useVersionUpdater() {
);
} else {
toast.success("No new browser versions found", {
- id: "version-update-progress",
duration: 3000,
description: "All browser versions are up to date",
});
@@ -92,9 +88,9 @@ export function useVersionUpdater() {
} else if (progress.status === "error") {
setIsUpdating(false);
setUpdateProgress(null);
+ dismissToast("unified-version-update");
toast.error("Failed to update browser versions", {
- id: "version-update-progress",
duration: 4000,
description: "Check your internet connection and try again",
});
@@ -159,7 +155,7 @@ export function useVersionUpdater() {
duration: 5000,
});
} else if (totalNewVersions > 0) {
- toast.success(`Found ${totalNewVersions} new browser versions!`, {
+ toast.success("Browser versions updated successfully", {
description: `Updated ${successfulUpdates} browsers successfully`,
duration: 4000,
});
diff --git a/src/lib/toast-utils.ts b/src/lib/toast-utils.ts
index ad75cdc..23a058d 100644
--- a/src/lib/toast-utils.ts
+++ b/src/lib/toast-utils.ts
@@ -43,6 +43,7 @@ export interface VersionUpdateToastProps extends BaseToastProps {
current: number;
total: number;
found: number;
+ current_browser?: string;
};
}
@@ -214,6 +215,7 @@ export function showVersionUpdateToast(
current: number;
total: number;
found: number;
+ current_browser?: string;
};
duration?: number;
},
@@ -301,3 +303,27 @@ export function dismissToast(id: string) {
export function dismissAllToasts() {
sonnerToast.dismiss();
}
+
+// Add a specific function for unified version update progress
+export function showUnifiedVersionUpdateToast(
+ title: string,
+ options?: {
+ id?: string;
+ description?: string;
+ progress?: {
+ current: number;
+ total: number;
+ found: number;
+ current_browser?: string;
+ };
+ duration?: number;
+ },
+) {
+ return showToast({
+ type: "version-update",
+ title,
+ id: "unified-version-update",
+ duration: Number.POSITIVE_INFINITY, // Keep showing until completed
+ ...options,
+ });
+}