diff options
Diffstat (limited to 'front/src/state')
-rw-r--r-- | front/src/state/state.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/front/src/state/state.ts b/front/src/state/state.ts index 2e747ea..715427d 100644 --- a/front/src/state/state.ts +++ b/front/src/state/state.ts @@ -19,10 +19,11 @@ export type LocalState = { setModal: (modal: JSX.Element | null) => void; composerData: ComposerData | null; setComposerData: (c: ComposerData | null) => void; - key: string; + pubkey: string; nostrFeed: Event[]; relays: Record<string, Event[]>; profiles: Map<string, UserProfile>; // pubkey key + addProfile: (key: string, u: UserProfile) => void; following: Map<string, FC>; followers: string[]; }; @@ -38,7 +39,7 @@ export const useStore = creator((set, get) => ({ await api.subscribeStore((data) => { console.log("store sub", data); if ("state" in data) { - const { feed, nostr, following, relays, profiles, key } = data.state; + const { feed, nostr, following, relays, profiles, pubkey } = data.state; const flwing = new Map(Object.entries(following as Record<string, FC>)); flwing.set(api!.airlock.our!, feed); set({ @@ -46,7 +47,7 @@ export const useStore = creator((set, get) => ({ nostrFeed: nostr, profiles: new Map(Object.entries(profiles)), following: flwing, - key, + pubkey, }); } else if ("fact" in data) { if ("post" in data.fact) { @@ -65,8 +66,13 @@ export const useStore = creator((set, get) => ({ }); set({ api }); }, - key: "", + pubkey: "", profiles: new Map(), + addProfile: (key, profile) => { + const profiles = get().profiles; + profiles.set(key, profile); + set({ profiles }); + }, relays: {}, nostrFeed: [], following: new Map(), |