Merge branch 'zustand/io/migration' of github.com:logspace-ai/langflow into zustand/io/migration
This commit is contained in:
commit
2960208bfe
1 changed files with 9 additions and 1 deletions
|
|
@ -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<DarkStoreType>((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<DarkStoreType>((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 }));
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue