Something went wrong. Try again.
A Bsky-like frontend using the atprotocol natively.
Something went wrong. Try again.
771 B · 26 lines
TypeScript
at main
123456789101112131415161718192021222324252627import { createContext, useContext } from 'react';import type { PostView } from '../api/types';
export interface BookmarkContextValue { bookmarkedUris: Set<string>; bookmarkPosts: Map<string, PostView>; loaded: boolean; addBookmark: (postUri: string, postCid: string) => Promise<void>; removeBookmark: (postUri: string) => Promise<void>; isBookmarked: (postUri: string) => boolean; reload: () => Promise<void>;}
export const BookmarkContext = createContext<BookmarkContextValue>({ bookmarkedUris: new Set(), bookmarkPosts: new Map(), loaded: false, addBookmark: async () => {}, removeBookmark: async () => {}, isBookmarked: () => false, reload: async () => {},});
export function useBookmarks() { return useContext(BookmarkContext);}