diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-11-16 18:26:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 18:26:22 -0800 |
commit | 357c752a213dbcf77e5333fa180cfef20a33842d (patch) | |
tree | e955e57cc1252b5fe759cde29185d62bb71bc339 /src/state/queries/notifications/feed.ts | |
parent | 3043b324681f1702ca53831701fb5cecd14c0efb (diff) | |
download | voidsky-357c752a213dbcf77e5333fa180cfef20a33842d.tar.zst |
Move the current agent to a global and reset RQ queries on agent change (#1946)
Diffstat (limited to 'src/state/queries/notifications/feed.ts')
-rw-r--r-- | src/state/queries/notifications/feed.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/state/queries/notifications/feed.ts b/src/state/queries/notifications/feed.ts index c1d9edb44..a47349827 100644 --- a/src/state/queries/notifications/feed.ts +++ b/src/state/queries/notifications/feed.ts @@ -8,7 +8,7 @@ import { } from '@atproto/api' import chunk from 'lodash.chunk' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' -import {useSession} from '../../session' +import {getAgent} from '../../session' import {useModerationOpts} from '../preferences' import {shouldFilterNotif} from './util' import {useMutedThreads} from '#/state/muted-threads' @@ -49,7 +49,6 @@ export interface FeedPage { } export function useNotificationFeedQuery(opts?: {enabled?: boolean}) { - const {agent} = useSession() const moderationOpts = useModerationOpts() const threadMutes = useMutedThreads() const enabled = opts?.enabled !== false @@ -64,7 +63,7 @@ export function useNotificationFeedQuery(opts?: {enabled?: boolean}) { staleTime: STALE.INFINITY, queryKey: RQKEY(), async queryFn({pageParam}: {pageParam: RQPageParam}) { - const res = await agent.listNotifications({ + const res = await getAgent().listNotifications({ limit: PAGE_SIZE, cursor: pageParam, }) @@ -79,7 +78,7 @@ export function useNotificationFeedQuery(opts?: {enabled?: boolean}) { // we fetch subjects of notifications (usually posts) now instead of lazily // in the UI to avoid relayouts - const subjects = await fetchSubjects(agent, notifsGrouped) + const subjects = await fetchSubjects(getAgent(), notifsGrouped) for (const notif of notifsGrouped) { if (notif.subjectUri) { notif.subject = subjects.get(notif.subjectUri) |