diff --git a/src/screens/Launch.svelte b/src/screens/Launch.svelte index 7918ff8..a3500bb 100644 --- a/src/screens/Launch.svelte +++ b/src/screens/Launch.svelte @@ -313,6 +313,8 @@ }; let restoreCandidate = $state<{ theme: Theme; backup: ThemeBackup } | undefined>(undefined); let restoringTheme = $state(false); + let uninstallCandidate = $state(undefined); + let uninstallingTheme = $state(false); let installedReportOpen = $state(false); let installedReportTarget = $state(null); let installedReportLoading = $state(false); @@ -528,6 +530,9 @@ }; const uninstallInstalledTheme = async (theme: Theme) => { + if (uninstallingTheme) return false; + uninstallingTheme = true; + try { const deleteResult = await deleteTheme(theme); if (deleteResult) { @@ -535,18 +540,36 @@ title: 'Theme uninstalled', description: `"${theme.name}" was removed from your library.`, }); - } else { - sileo.error({ - title: 'Could not uninstall theme', - description: 'The theme files could not be removed.', - }); + return true; } + + sileo.error({ + title: 'Could not uninstall theme', + description: 'The theme files could not be removed.', + }); + return false; } catch (err) { console.error(err); sileo.error({ title: 'Could not uninstall theme', description: err instanceof Error ? err.message : String(err), }); + return false; + } finally { + uninstallingTheme = false; + } + }; + + const requestThemeUninstall = (theme: Theme) => { + if (theme.status !== 'installed' || theme.name === 'Default' || uninstallingTheme) return; + uninstallCandidate = theme; + }; + + const confirmThemeUninstall = async () => { + const theme = uninstallCandidate; + if (!theme) return; + if (await uninstallInstalledTheme(theme)) { + uninstallCandidate = undefined; } }; @@ -2404,6 +2427,51 @@ + + +
+ + Uninstall theme? +
+
+ Remove {uninstallCandidate?.name} from your library? This + deletes the local theme files and any unpublished changes. If the theme is published to the Workshop, + that copy is not affected. +
+
+ + +
+
+
+ -
+
{#if activeThemesTab === 'workshop'}
@@ -4249,7 +4317,7 @@
{:else}
@@ -4590,11 +4658,13 @@ {/if} {#if canUninstallTheme} - + {#if canEditTheme || canRestoreTheme || canUpdateTheme || canReportTheme} + + {/if} void uninstallInstalledTheme(theme)} + onclick={() => requestThemeUninstall(theme)} > {#if theme.status === 'deleting'}