From 455e6fd60e24b06efbaf1e9a466b99b399de76e2 Mon Sep 17 00:00:00 2001 From: Beebles <102569435+beebls@users.noreply.github.com> Date: Mon, 2 Oct 2023 14:14:41 -0600 Subject: [PATCH] fix #102 and #103 --- src/backend/backendHelpers/toggleTheme.tsx | 3 ++- src/python.ts | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/backend/backendHelpers/toggleTheme.tsx b/src/backend/backendHelpers/toggleTheme.tsx index d213080..7aa12e0 100644 --- a/src/backend/backendHelpers/toggleTheme.tsx +++ b/src/backend/backendHelpers/toggleTheme.tsx @@ -69,9 +69,10 @@ export async function toggleTheme( const { localThemeList } = python.globalState!.getPublicState(); // This is copied from the desktop codebase - // If we refactor the desktop version of this function (which we probably should) this should also be refactored await python.generatePresetFromThemeNames( selectedPreset.name, localThemeList.filter((e) => e.enabled && !e.flags.includes(Flags.isPreset)).map((e) => e.name) ); + // Getting the new data for the preset + await python.getInstalledThemes(); } diff --git a/src/python.ts b/src/python.ts index 8b4301b..74f0d3b 100644 --- a/src/python.ts +++ b/src/python.ts @@ -78,8 +78,17 @@ export async function scheduleCheckForUpdates() { export async function changePreset(themeName: string, themeList: Theme[]) { return new Promise(async (resolve) => { - // Disables all themes before enabling the preset - await Promise.all(themeList.filter((e) => e.enabled).map((e) => setThemeState(e.name, false))); + const { selectedPreset } = globalState!.getPublicState(); + + if (selectedPreset) { + // If you already have a preset enabled, since all currently enabled themes are part of that preset, you only need to disable it, not every theme + await setThemeState(selectedPreset!.name, false); + } else { + // On the contrary, if you have no preset, you still do have to disable the current themes and then enable the preset + await Promise.all( + themeList.filter((e) => e.enabled).map((e) => setThemeState(e.name, false)) + ); + } if (themeName !== "None") { await setThemeState(themeName, true);