diff options
author | polwex <polwex@sortug.com> | 2025-09-17 21:45:18 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-09-17 21:45:18 +0700 |
commit | 985fa2f7c99832cdf3c3351d2273c8fd05402b78 (patch) | |
tree | bc727486a89ad05e588754f8de8b1096400a3d31 /front/src/state/state.ts | |
parent | f0df4c7297a05bd592d8717b8997284c80fd0500 (diff) |
basic comms working
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; |