Skip to content

Commit

Permalink
fix preset dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
beebls committed Oct 12, 2024
1 parent d5c5546 commit e8a349c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@
"react-dom"
]
}
}
},
"packageManager": "[email protected]+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
}
2 changes: 2 additions & 0 deletions src/backend/state/theme-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ export const createCSSLoaderStore = (backend: Backend) =>
} catch (error) {}
},
installTheme: async (themeId: string) => {
set({ isWorking: true });
try {
await backend.downloadThemeFromUrl(themeId, apiUrl);
const { updateStatuses, reloadThemes } = get();
Expand All @@ -381,6 +382,7 @@ export const createCSSLoaderStore = (backend: Backend) =>
updateStatusesClone.push([themeId, "installed", false]);
set({ updateStatuses: updateStatusesClone });
} catch (error) {}
set({ isWorking: false });
},
toggleTheme: async (
theme: Theme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export function PresetSelectionDropdown() {
const themes = useCSSLoaderValue("themes");
const selectedPreset = useCSSLoaderValue("selectedPreset");
const changePreset = useCSSLoaderAction("changePreset");
const presets = useMemo(() => themes.filter((e) => e.flags.includes(Flags.isPreset)), [themes]);
const hasInvalidPresetState = presets.length > 1;
const presets = themes.filter((e) => e.flags.includes(Flags.isPreset));
const hasInvalidPresetState = presets.filter((e) => e.enabled).length > 1;

const [render, rerender] = useForcedRerender();

console.log(themes, presets, selectedPreset, hasInvalidPresetState);

return (
<>
{render && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function ExpandedViewButtonsSection() {
const toggleStar = useExpandedViewAction("toggleStar");

const apiFullToken = useCSSLoaderValue("apiFullToken");
// Because this is an action handled by the expanded view store and not the backend theme store, we can't just use the backend's isWorking
const [starButtonBlurred, setStarButtonBlurred] = useState<boolean>(false);

const isWorking = useCSSLoaderValue("isWorking");
Expand Down
5 changes: 4 additions & 1 deletion src/modules/theme-store/context/ThemeBrowserStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ export function ThemeBrowserStoreProvider({
getThemes();
}
},
refreshThemes: async () => {},
refreshThemes: async () => {
const { getThemes } = get();
await getThemes();
},
getThemes: async () => {
try {
const { searchOpts } = get();
Expand Down
14 changes: 13 additions & 1 deletion src/styles/styles-as-string.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { gamepadDialogClasses } from "@decky/ui";

export const styles = `
/* THIS FILE IS NOT USED IN BUILD */
/* ANY MODIFICATIONS HERE MUST BE COPY PASTED INTO stylesAsString.ts */
/* THAT IS NEEDED FOR STATIC CLASS INJECTIOn */
.flex {
display: flex !important;
}
Expand Down Expand Up @@ -343,7 +347,7 @@ export const styles = `
.cl_expandedview_container {
background: rgb(27, 40, 56) !important;
padding: auto 1rem !important;
padding: 0 1rem !important;
gap: 1rem !important;
display: flex !important;
justify-content: space-between !important;
Expand Down Expand Up @@ -403,6 +407,14 @@ export const styles = `
}
}
.cl_expandedview_infocontainer {
padding-left: 1rem;
padding-right: 1rem;
display: flex;
flex-direction: column;
gap: 0.25rem
}
.cl_expandedview_title {
white-space: nowrap !important;
text-overflow: ellipsis !important;
Expand Down

0 comments on commit e8a349c

Please sign in to comment.