import { create } from "zustand"; import { NDKEvent, type NDKUser } from "@nostr-dev-kit/ndk"; type Settings = {}; interface CurrentUserState { currentUser: NDKUser | null; follows: Set; calendars: Set; setCalendars: (calendars: Set) => void; settings: Settings; setCurrentUser: (user: NDKUser | null) => void; updateCurrentUser: (user: Partial) => void; setFollows: (follows: Set) => void; addFollow: (follow: NDKUser) => void; } const currentUserStore = create()((set) => ({ currentUser: null, follows: new Set(), calendars: new Set(), settings: {}, setCurrentUser: (user) => set((state) => ({ ...state, currentUser: user })), updateCurrentUser: (user) => set((state) => ({ ...state, currentUser: { ...state.currentUser, ...user } as NDKUser, })), setFollows: (follows) => set((state) => ({ ...state, follows: follows })), setCalendars: (calendars) => set((state) => ({ ...state, calendars: calendars })), addFollow: (follow) => set((state) => ({ ...state, follows: new Set(state.follows).add(follow) })), })); export default currentUserStore;