feat: don't spam update notification, show more concise toasts, don't fetch unsupported browser updates

This commit is contained in:
zhom
2025-06-14 16:58:55 +04:00
parent c99eee2c21
commit 545c518a55
10 changed files with 200 additions and 108 deletions
+31 -12
View File
@@ -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();
}
},
);
+20 -24
View File
@@ -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,
});