diff --git a/src/frontend/src/stores/darkStore.tsx b/src/frontend/src/stores/darkStore.tsx index 6278e59c7..cc58944cc 100644 --- a/src/frontend/src/stores/darkStore.tsx +++ b/src/frontend/src/stores/darkStore.tsx @@ -2,9 +2,11 @@ import { create } from "zustand"; import { getRepoStars, getVersion } from "../controllers/API"; import { DarkStoreType } from "../types/zustand/dark"; +const startedStars = Number(window.localStorage.getItem("githubStars")) ?? 0; + export const useDarkStore = create((set) => ({ dark: JSON.parse(window.localStorage.getItem("isDark")!) ?? false, - stars: 0, + stars: startedStars, version: "", setDark: (dark) => set(() => ({ dark: dark })), refreshVersion: () => { @@ -13,7 +15,13 @@ export const useDarkStore = create((set) => ({ }); }, refreshStars: () => { + if (window.localStorage.getItem("githubStars") !== null) { + set(() => ({ stars: startedStars })); + return; + } + getRepoStars("logspace-ai", "langflow").then((res) => { + window.localStorage.setItem("githubStars", res.toString()); set(() => ({ stars: res })); }); },