Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Download web_app/src/hooks/useTopicStories.ts from CommunityOne/open-navigator: direct link, hf CLI and curl.
- Browser
- Download file 839 Bytes
-
https://huggingface.co/spaces/CommunityOne/open-navigator/resolve/main/web_app/src/hooks/useTopicStories.ts
- Command line
-
hf download hf://spaces/CommunityOne/open-navigator/web_app/src/hooks/useTopicStories.ts
-
curl -L -o useTopicStories.ts https://huggingface.co/spaces/CommunityOne/open-navigator/resolve/main/web_app/src/hooks/useTopicStories.ts
839 Bytes
| import { useMemo } from 'react' | |
| import { useQuery } from '@tanstack/react-query' | |
| import { fetchTopics } from '../api/topics' | |
| import { deriveTopicStories, liveStories } from '../utils/topicStories' | |
| /** | |
| * The live topic stories (#1133), from the national topic catalog: curated topics with linked meetings. Read nationally on | |
| * purpose: whether a story exists does not depend on the page's place (the story itself shows an empty place honestly). | |
| */ | |
| export function useTopicStories() { | |
| const q = useQuery({ queryKey: ['topics', 'catalog', 'national'], queryFn: () => fetchTopics(), staleTime: 10 * 60_000, retry: 1 }) | |
| const stories = useMemo(() => deriveTopicStories(q.data), [q.data]) | |
| const live = useMemo(() => liveStories(stories), [stories]) | |
| return { topics: q.data, stories, live, pending: q.isPending, failed: q.isError } | |
| } | |