diff --git a/src/app/page.tsx b/src/app/page.tsx index a1b927a..e102405 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -192,12 +192,20 @@ export default function Home() { ); // Version updater for handling version fetching progress events and auto-updates - useVersionUpdater(); + const { isUpdating: isVersionUpdating } = useVersionUpdater(); // Auto-update functionality - use the existing hook for compatibility const updateNotifications = useUpdateNotifications(loadProfiles); const { checkForUpdates, isUpdating } = updateNotifications; + // Combined update checking function for per-browser blocking + const isBrowserUpdating = useCallback( + (browser: string) => { + return isVersionUpdating || isUpdating(browser); + }, + [isVersionUpdating, isUpdating], + ); + // Profiles loader with update check (for initial load and manual refresh) const loadProfilesWithUpdateCheck = useCallback(async () => { try { @@ -733,7 +741,7 @@ export default function Home() { return (
- + ))} diff --git a/src/components/profile-data-table.tsx b/src/components/profile-data-table.tsx index f3bbd6d..52d287d 100644 --- a/src/components/profile-data-table.tsx +++ b/src/components/profile-data-table.tsx @@ -267,6 +267,14 @@ export function ProfilesDataTable({ // Handle icon/checkbox click const handleIconClick = React.useCallback( (profileName: string) => { + const profile = filteredData.find((p) => p.name === profileName); + if (!profile) return; + + // Prevent selection of profiles whose browsers are updating + if (!browserState.canSelectProfile(profile)) { + return; + } + setShowCheckboxes(true); setSelectedProfiles((prev) => { const newSet = new Set(prev); @@ -289,7 +297,7 @@ export function ProfilesDataTable({ return newSet; }); }, - [onSelectedProfilesChange], + [filteredData, browserState.canSelectProfile, onSelectedProfilesChange], ); // Handle checkbox change diff --git a/src/hooks/use-browser-support.ts b/src/hooks/use-browser-support.ts index b727b9d..2b26e5b 100644 --- a/src/hooks/use-browser-support.ts +++ b/src/hooks/use-browser-support.ts @@ -104,8 +104,10 @@ export function useBrowserState( // If the profile is already running, it can always be stopped if (isRunning) return true; - // If browser is updating, it cannot be launched - if (isBrowserUpdating) return false; + // If THIS specific browser is updating or downloading, block this profile + if (isBrowserUpdating) { + return false; + } // For single-instance browsers, check if any instance is running if (isSingleInstanceBrowser(profile.browser)) { @@ -132,6 +134,12 @@ export function useBrowserState( if (!isClient) return false; const isRunning = runningProfiles.has(profile.name); + const isBrowserUpdating = isUpdating?.(profile.browser) ?? false; + + // If this specific browser is updating or downloading, block it + if (isBrowserUpdating) { + return false; + } // For single-instance browsers (Tor and Mullvad) if (isSingleInstanceBrowser(profile.browser)) { @@ -151,7 +159,26 @@ export function useBrowserState( // For other browsers, any profile can be used return true; }, - [profiles, runningProfiles, isClient, isSingleInstanceBrowser], + [profiles, runningProfiles, isClient, isSingleInstanceBrowser, isUpdating], + ); + + /** + * Check if a profile can be selected for actions (delete, move group, etc.) + */ + const canSelectProfile = useCallback( + (profile: BrowserProfile): boolean => { + if (!isClient) return false; + + const isBrowserUpdating = isUpdating?.(profile.browser) ?? false; + + // If this specific browser is updating or downloading, block selection + if (isBrowserUpdating) { + return false; + } + + return true; + }, + [isClient, isUpdating], ); /** @@ -203,6 +230,12 @@ export function useBrowserState( if (canUseForLinks) return null; + const isBrowserUpdating = isUpdating?.(profile.browser) ?? false; + + if (isBrowserUpdating) { + return `${getBrowserDisplayName(profile.browser)} is being updated. Please wait for the update to complete.`; + } + if (isSingleInstanceBrowser(profile.browser)) { const browserDisplayName = profile.browser === "tor-browser" ? "TOR" : "Mullvad"; @@ -226,6 +259,7 @@ export function useBrowserState( isClient, canUseProfileForLinks, isSingleInstanceBrowser, + isUpdating, ], ); @@ -235,6 +269,7 @@ export function useBrowserState( isAnyInstanceRunning, canLaunchProfile, canUseProfileForLinks, + canSelectProfile, getLaunchTooltipContent, getProfileTooltipContent, };