Skip to content

Commit

Permalink
add visual feedback to refresh button
Browse files Browse the repository at this point in the history
  • Loading branch information
beebls committed Oct 12, 2024
1 parent fc872d4 commit ba538cf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
8 changes: 7 additions & 1 deletion src/backend/services/backend-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ export class Backend {
await Backend.repository.call<[], void>("reset", []);
}
async dummyFunction(): Promise<boolean> {
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]);
Expand Down
26 changes: 21 additions & 5 deletions src/backend/state/theme-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<string | undefined> => {
const { apiFullToken, apiTokenExpireDate } = get();
Expand Down
14 changes: 0 additions & 14 deletions src/decky-patches/unminify-mode/dump-mappings.ts

This file was deleted.

5 changes: 4 additions & 1 deletion src/modules/qam-tab-page/components/QamRefreshButton.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<PanelSectionRow>
<ButtonItem
disabled={isWorking}
onClick={() => {
console.log("TEST");
void reloadPlugin();
}}
layout="below"
Expand Down

0 comments on commit ba538cf

Please sign in to comment.