import { createContext, useContext } from 'react' export type TFollowListContext = { followings: string[] follow: (pubkey: string) => Promise /** One fetch + one kind-3 publish after merging all pubkeys (use for follow packs, not per-user loops). */ followMany: (pubkeys: string[]) => Promise unfollow: (pubkey: string) => Promise } export const FollowListContext = createContext(undefined) export const useFollowList = (): TFollowListContext => { const context = useContext(FollowListContext) if (!context) { throw new Error('useFollowList must be used within a FollowListProvider') } return context } /** Same as {@link useFollowList} but returns undefined outside the provider (avoids HMR / refresh-boundary crashes). */ export function useFollowListOptional(): TFollowListContext | undefined { return useContext(FollowListContext) }