From 3ac1575c587a62a55b54a2f8c21f15d2e64b9afe Mon Sep 17 00:00:00 2001 From: Beebles <102569435+beebls@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:17:08 -0700 Subject: [PATCH] (UNTESTED): fix target override --- .../theme-store/context/ThemeBrowserSharedStore.tsx | 2 +- src/modules/theme-store/context/ThemeBrowserStore.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/theme-store/context/ThemeBrowserSharedStore.tsx b/src/modules/theme-store/context/ThemeBrowserSharedStore.tsx index 754d531..8693ed7 100644 --- a/src/modules/theme-store/context/ThemeBrowserSharedStore.tsx +++ b/src/modules/theme-store/context/ThemeBrowserSharedStore.tsx @@ -18,7 +18,7 @@ interface IThemeBrowserSharedStore extends ThemeBrowserSharedStoreValues, ThemeBrowserSharedStoreActions {} -const themeBrowserSharedStore = createStore((set) => { +export const themeBrowserSharedStore = createStore((set) => { return { browserCardSize: 3, targetOverride: "", diff --git a/src/modules/theme-store/context/ThemeBrowserStore.tsx b/src/modules/theme-store/context/ThemeBrowserStore.tsx index 067d1df..8b005c1 100644 --- a/src/modules/theme-store/context/ThemeBrowserStore.tsx +++ b/src/modules/theme-store/context/ThemeBrowserStore.tsx @@ -3,7 +3,7 @@ import { FilterQueryResponse, ThemeQueryRequest, ThemeQueryResponse } from "@/ty import { StoreApi, createStore, useStore } from "zustand"; import { getCSSLoaderState } from "@/backend"; import { isEqual } from "lodash"; -import { getThemeBrowserSharedState } from "./ThemeBrowserSharedStore"; +import { getThemeBrowserSharedState, themeBrowserSharedStore } from "./ThemeBrowserSharedStore"; interface ThemeBrowserStoreValues { loading: boolean; @@ -83,6 +83,12 @@ export function ThemeBrowserStoreProvider({ try { await get().getFilters(); await get().getThemes(); + + themeBrowserSharedStore.subscribe((state, prevState) => { + if (state.targetOverride !== prevState.targetOverride) { + get().getThemes(); + } + }); } catch (error) {} }, getFilters: async () => {