diff options
Diffstat (limited to 'front/src/state/state.ts')
-rw-r--r-- | front/src/state/state.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/front/src/state/state.ts b/front/src/state/state.ts index 01b8ea1..2e747ea 100644 --- a/front/src/state/state.ts +++ b/front/src/state/state.ts @@ -6,6 +6,7 @@ import { create } from "zustand"; import type { UserProfile } from "@/types/nostrill"; import type { Event } from "@/types/nostr"; import type { FC, Poast } from "@/types/trill"; +import { useShallow } from "zustand/shallow"; // TODO handle airlock connection issues // the SSE pipeline has a "status-update" event FWIW // type AirlockState = "connecting" | "connected" | "failed"; @@ -27,7 +28,7 @@ export type LocalState = { }; const creator = create<LocalState>(); -const useLocalState = creator((set, get) => ({ +export const useStore = creator((set, get) => ({ isNew: false, api: null, init: async () => { @@ -78,4 +79,8 @@ const useLocalState = creator((set, get) => ({ setComposerData: (composerData) => set({ composerData }), })); -export default useLocalState; +const useShallowStore = <T extends (state: LocalState) => any>( + selector: T, +): ReturnType<T> => useStore(useShallow(selector)); + +export default useShallowStore; |