summaryrefslogtreecommitdiff
path: root/front/src/state/state.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-09-18 00:24:39 +0700
committerpolwex <polwex@sortug.com>2025-09-18 00:24:39 +0700
commit4b016c908dda2019f3bf89e5a3d2eae535e5fbd2 (patch)
tree639613aa8bcc3d36b5165a32ece4a421dabde4c8 /front/src/state/state.ts
parent985fa2f7c99832cdf3c3351d2273c8fd05402b78 (diff)
oioi
Diffstat (limited to 'front/src/state/state.ts')
-rw-r--r--front/src/state/state.ts14
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(),