From d344d5ed6e80f68343cd7c03f010d3bd5a82d20f Mon Sep 17 00:00:00 2001 From: beebls Date: Thu, 15 Sep 2022 16:30:48 -0600 Subject: [PATCH 1/2] Dependency toast error management, and decky-frontend-lib update --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- src/components/ColorPickerModal.tsx | 6 +++--- src/components/ThemePatch.tsx | 4 ++-- src/components/ThemeToggle.tsx | 9 ++++----- src/python.ts | 17 ++++++++++++----- src/theme-manager/ThemeBrowserPage.tsx | 4 ++-- 7 files changed, 29 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 6d6f8a5..3462d2e 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "typescript": "^4.6.4" }, "dependencies": { - "decky-frontend-lib": "^1.7.5", + "decky-frontend-lib": "3.0.0", "react-icons": "^4.3.1" }, "pnpm": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e132b5c..34d3e0b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,7 +8,7 @@ specifiers: '@rollup/plugin-typescript': ^8.3.2 '@types/react': 16.14.0 '@types/webpack': ^5.28.0 - decky-frontend-lib: ^1.7.5 + decky-frontend-lib: 3.0.0 react-icons: ^4.3.1 rollup: ^2.70.2 rollup-plugin-import-assets: ^1.1.1 @@ -18,7 +18,7 @@ specifiers: typescript: ^4.6.4 dependencies: - decky-frontend-lib: 1.7.5 + decky-frontend-lib: 3.0.0 react-icons: 4.4.0 devDependencies: @@ -632,8 +632,8 @@ packages: resolution: {integrity: sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==} dev: true - /decky-frontend-lib/1.7.5: - resolution: {integrity: sha512-1OX/Ix9W76gF0NJjfm0k/01LYPmC2k/k+k/qqH8JJPlPHh5+W5P8ZG2T8m5wKsqoP7jx2W3k7RNZBh9vAqFoFw==} + /decky-frontend-lib/3.0.0: + resolution: {integrity: sha512-ZqJ9ii7QoYWHFfkU8hV82IHi3+McZDmE4wS22duXpgRI8r5BBMiZItw6tYkc24ZtsJIVso83FFt7adcEBqBwJA==} dependencies: minimist: 1.2.6 dev: false @@ -976,7 +976,7 @@ packages: /minimist/1.2.6: resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==} - + /nanoid/3.3.4: resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} diff --git a/src/components/ColorPickerModal.tsx b/src/components/ColorPickerModal.tsx index 6bbf156..1236f86 100644 --- a/src/components/ColorPickerModal.tsx +++ b/src/components/ColorPickerModal.tsx @@ -1,4 +1,4 @@ -import { ModalRoot, SliderField } from "decky-frontend-lib"; +import { ConfirmModal, SliderField } from "decky-frontend-lib"; import { CSSProperties, useState, VFC } from "react"; interface ColorPickerModalProps { @@ -79,7 +79,7 @@ export const ColorPickerModal: VFC = ({ } `} - { @@ -158,7 +158,7 @@ export const ColorPickerModal: VFC = ({ /> - + ); }; diff --git a/src/components/ThemePatch.tsx b/src/components/ThemePatch.tsx index fbce82d..612b506 100644 --- a/src/components/ThemePatch.tsx +++ b/src/components/ThemePatch.tsx @@ -117,8 +117,8 @@ export const ThemePatch: VFC<{ selectedOption={data.index} onChange={(index) => { data.index = index.data; - data.value = index.label; - setLabel(index.label); + data.value = index.label as string; + setLabel(data.value); python.execute( python.setPatchOfTheme(data.theme.name, data.name, data.value) ); diff --git a/src/components/ThemeToggle.tsx b/src/components/ThemeToggle.tsx index 48ffecc..e29079c 100644 --- a/src/components/ThemeToggle.tsx +++ b/src/components/ThemeToggle.tsx @@ -20,6 +20,10 @@ export const ThemeToggle: VFC<{ data: Theme; setThemeList: any }> = ({ label={data.name} description={data.description} onChange={(switchValue: boolean) => { + // Actually enabling the theme + python.resolve(python.setThemeState(data.name, switchValue), () => { + python.resolve(python.getThemes(), setThemeList); + }); // Dependency Toast if (switchValue === true && data.dependencies.length > 0) { python.toast( @@ -30,11 +34,6 @@ export const ThemeToggle: VFC<{ data: Theme; setThemeList: any }> = ({ } required for this theme` ); } - - // Actually enabling the theme - python.resolve(python.setThemeState(data.name, switchValue), () => { - python.resolve(python.getThemes(), setThemeList); - }); }} /> diff --git a/src/python.ts b/src/python.ts index c78fefa..84b9feb 100644 --- a/src/python.ts +++ b/src/python.ts @@ -72,11 +72,18 @@ export function setComponentOfThemePatch( } export function toast(title: string, message: string) { - return server?.toaster.toast({ - title: title, - body: message, - duration: 8000, - }); + // This is a weirdo self-invoking function, but it works. + return (() => { + try { + return server?.toaster.toast({ + title: title, + body: message, + duration: 8000, + }); + } catch (e) { + console.log("CSSLoader Toaster Error", e); + } + })(); } export function downloadTheme(uuid: string): Promise { diff --git a/src/theme-manager/ThemeBrowserPage.tsx b/src/theme-manager/ThemeBrowserPage.tsx index c4b045e..c99b380 100644 --- a/src/theme-manager/ThemeBrowserPage.tsx +++ b/src/theme-manager/ThemeBrowserPage.tsx @@ -40,7 +40,7 @@ export const ThemeBrowserPage: VFC = () => { // const [selectedTarget, setTarget] = useState({ data: 1, label: "All", }); // const [selectedSort, setSort] = useState(3); - const [backendVersion, setBackendVer] = useState(2); + const [backendVersion, setBackendVer] = useState(3); function reloadBackendVer() { python.resolve(python.getBackendVersion(), setBackendVer); } @@ -161,7 +161,7 @@ export const ThemeBrowserPage: VFC = () => { .filter(searchFilter) .filter((e: browseThemeEntry) => { if (selectedTarget.label === "All") { - return e.target !== "Background" + return e.target !== "Background"; } else if (selectedTarget.label === "Installed") { const strValue = checkIfThemeInstalled(e); return strValue === "installed" || strValue === "outdated"; From 6140286059a5ae63791b329c9c7a997250f364b7 Mon Sep 17 00:00:00 2001 From: suchmememanyskill <38142618+suchmememanyskill@users.noreply.github.com> Date: Sat, 17 Sep 2022 00:51:46 +0200 Subject: [PATCH 2/2] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3462d2e..2b61ea6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SDH-CssLoader", - "version": "1.2.0", + "version": "1.2.1", "description": "A css loader", "scripts": { "build": "shx rm -rf dist && rollup -c",