diff --git a/src/backend/services/backend-service.ts b/src/backend/services/backend-service.ts index 79cbb5f..003f551 100644 --- a/src/backend/services/backend-service.ts +++ b/src/backend/services/backend-service.ts @@ -22,7 +22,13 @@ export class Backend { await Backend.repository.call<[], void>("reset", []); } async dummyFunction(): Promise { - return await Backend.repository.call<[], boolean>("dummy_function", []); + // While most of the try catching should happen in the stores, this makes sense here + try { + const value = await Backend.repository.call<[], boolean>("dummy_function", []); + return value; + } catch (error) { + return false; + } } async storeRead(key: string) { return Backend.repository.call<[string], string>("store_read", [key]); diff --git a/src/backend/state/theme-store.ts b/src/backend/state/theme-store.ts index 5007c3c..8289e22 100644 --- a/src/backend/state/theme-store.ts +++ b/src/backend/state/theme-store.ts @@ -171,7 +171,9 @@ export const createCSSLoaderStore = (backend: Backend) => const { bulkThemeUpdateCheck, scheduleBulkThemeUpdateCheck } = get(); await bulkThemeUpdateCheck(); scheduleBulkThemeUpdateCheck(); - } catch (error) {} + } catch (error) { + console.log("Error During Initialzation", error); + } }, deactivate: () => { const { updateCheckTimeout } = get(); @@ -181,17 +183,31 @@ export const createCSSLoaderStore = (backend: Backend) => backend.toast("CSS Loader", message); }, reloadPlugin: async () => { + set({ isWorking: true }); try { - const { reloadThemes, bulkThemeUpdateCheck } = get(); - await reloadThemes(); - await bulkThemeUpdateCheck(); + const { reloadThemes, initializeStore, bulkThemeUpdateCheck, dummyFunctionResult } = + get(); + + // If the dummy func result is false, the plugin never initialized properly anyway, so we should just re-initialize the whole thing. + if (dummyFunctionResult === false) { + await initializeStore(); + } else { + // Otherwise, we can just reload the necessary stuff + const dummyFunctionResult = await backend.dummyFunction(); + set({ dummyFunctionResult }); + await reloadThemes(); + await bulkThemeUpdateCheck(); + } } catch (error) {} + set({ isWorking: false }); }, reloadThemes: async () => { try { await backend.reset(); await get().getThemes(); - } catch (error) {} + } catch (error) { + console.error("Error Reloading Themes", error); + } }, refreshToken: async (): Promise => { const { apiFullToken, apiTokenExpireDate } = get(); diff --git a/src/decky-patches/unminify-mode/dump-mappings.ts b/src/decky-patches/unminify-mode/dump-mappings.ts deleted file mode 100644 index 8a76b63..0000000 --- a/src/decky-patches/unminify-mode/dump-mappings.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { saveMappings } from "../python"; - -export async function dumpMappings() { - try { - if (!window.DFL) return; - const map = window.DFL.classModuleMap as Map; - if (!map) return; - const jsonStr = JSON.stringify(Object.fromEntries(map)); - - await saveMappings(jsonStr); - } catch (error) { - console.error("ERROR SAVING MAPPINGS", error); - } -} diff --git a/src/modules/qam-tab-page/components/QamRefreshButton.tsx b/src/modules/qam-tab-page/components/QamRefreshButton.tsx index 1abbe62..6ce94f2 100644 --- a/src/modules/qam-tab-page/components/QamRefreshButton.tsx +++ b/src/modules/qam-tab-page/components/QamRefreshButton.tsx @@ -1,12 +1,15 @@ import { ButtonItem, PanelSectionRow } from "@decky/ui"; -import { useCSSLoaderAction } from "@/backend"; +import { useCSSLoaderAction, useCSSLoaderValue } from "@/backend"; export function QamRefreshButton() { const reloadPlugin = useCSSLoaderAction("reloadPlugin"); + const isWorking = useCSSLoaderValue("isWorking"); return ( { + console.log("TEST"); void reloadPlugin(); }} layout="below"