diff options
Diffstat (limited to 'src/state')
-rw-r--r-- | src/state/queries/my-blocked-accounts.ts | 2 | ||||
-rw-r--r-- | src/state/queries/my-muted-accounts.ts | 2 | ||||
-rw-r--r-- | src/state/queries/notifications/util.ts | 3 | ||||
-rw-r--r-- | src/state/queries/post-liked-by.ts | 2 | ||||
-rw-r--r-- | src/state/queries/post-reposted-by.ts | 2 | ||||
-rw-r--r-- | src/state/queries/post-thread.ts | 2 | ||||
-rw-r--r-- | src/state/queries/post.ts | 3 | ||||
-rw-r--r-- | src/state/queries/profile-feedgens.ts | 2 | ||||
-rw-r--r-- | src/state/queries/profile-followers.ts | 2 | ||||
-rw-r--r-- | src/state/queries/profile-lists.ts | 3 | ||||
-rw-r--r-- | src/state/queries/profile.ts | 4 | ||||
-rw-r--r-- | src/state/queries/resolve-uri.ts | 2 | ||||
-rw-r--r-- | src/state/queries/service.ts | 3 | ||||
-rw-r--r-- | src/state/queries/suggested-follows.ts | 2 |
14 files changed, 8 insertions, 26 deletions
diff --git a/src/state/queries/my-blocked-accounts.ts b/src/state/queries/my-blocked-accounts.ts index 4d5bd7a0e..2c099c63d 100644 --- a/src/state/queries/my-blocked-accounts.ts +++ b/src/state/queries/my-blocked-accounts.ts @@ -2,7 +2,6 @@ import {AppBskyGraphGetBlocks} from '@atproto/api' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' import {getAgent} from '#/state/session' -import {STALE} from '#/state/queries' export const RQKEY = () => ['my-blocked-accounts'] type RQPageParam = string | undefined @@ -15,7 +14,6 @@ export function useMyBlockedAccountsQuery() { QueryKey, RQPageParam >({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(), async queryFn({pageParam}: {pageParam: RQPageParam}) { const res = await getAgent().app.bsky.graph.getBlocks({ diff --git a/src/state/queries/my-muted-accounts.ts b/src/state/queries/my-muted-accounts.ts index 1d686637a..a175931b5 100644 --- a/src/state/queries/my-muted-accounts.ts +++ b/src/state/queries/my-muted-accounts.ts @@ -2,7 +2,6 @@ import {AppBskyGraphGetMutes} from '@atproto/api' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' import {getAgent} from '#/state/session' -import {STALE} from '#/state/queries' export const RQKEY = () => ['my-muted-accounts'] type RQPageParam = string | undefined @@ -15,7 +14,6 @@ export function useMyMutedAccountsQuery() { QueryKey, RQPageParam >({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(), async queryFn({pageParam}: {pageParam: RQPageParam}) { const res = await getAgent().app.bsky.graph.getMutes({ diff --git a/src/state/queries/notifications/util.ts b/src/state/queries/notifications/util.ts index 48e1b8dd8..b8f320473 100644 --- a/src/state/queries/notifications/util.ts +++ b/src/state/queries/notifications/util.ts @@ -119,7 +119,8 @@ function groupNotifications( Math.abs(ts2 - ts) < MS_2DAY && notif.reason === groupedNotif.notification.reason && notif.reasonSubject === groupedNotif.notification.reasonSubject && - notif.author.did !== groupedNotif.notification.author.did + notif.author.did !== groupedNotif.notification.author.did && + notif.isRead === groupedNotif.notification.isRead ) { groupedNotif.additional = groupedNotif.additional || [] groupedNotif.additional.push(notif) diff --git a/src/state/queries/post-liked-by.ts b/src/state/queries/post-liked-by.ts index 33b379a0c..528b3be70 100644 --- a/src/state/queries/post-liked-by.ts +++ b/src/state/queries/post-liked-by.ts @@ -2,7 +2,6 @@ import {AppBskyFeedGetLikes} from '@atproto/api' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' import {getAgent} from '#/state/session' -import {STALE} from '#/state/queries' const PAGE_SIZE = 30 type RQPageParam = string | undefined @@ -18,7 +17,6 @@ export function usePostLikedByQuery(resolvedUri: string | undefined) { QueryKey, RQPageParam >({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(resolvedUri || ''), async queryFn({pageParam}: {pageParam: RQPageParam}) { const res = await getAgent().getLikes({ diff --git a/src/state/queries/post-reposted-by.ts b/src/state/queries/post-reposted-by.ts index 3a6fe1633..f9a80056f 100644 --- a/src/state/queries/post-reposted-by.ts +++ b/src/state/queries/post-reposted-by.ts @@ -2,7 +2,6 @@ import {AppBskyFeedGetRepostedBy} from '@atproto/api' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' import {getAgent} from '#/state/session' -import {STALE} from '#/state/queries' const PAGE_SIZE = 30 type RQPageParam = string | undefined @@ -18,7 +17,6 @@ export function usePostRepostedByQuery(resolvedUri: string | undefined) { QueryKey, RQPageParam >({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(resolvedUri || ''), async queryFn({pageParam}: {pageParam: RQPageParam}) { const res = await getAgent().getRepostedBy({ diff --git a/src/state/queries/post-thread.ts b/src/state/queries/post-thread.ts index 4b586c862..d40af1fe2 100644 --- a/src/state/queries/post-thread.ts +++ b/src/state/queries/post-thread.ts @@ -7,7 +7,6 @@ import {useQuery, useQueryClient, QueryClient} from '@tanstack/react-query' import {getAgent} from '#/state/session' import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types' -import {STALE} from '#/state/queries' import {findPostInQueryData as findPostInFeedQueryData} from './post-feed' import {findPostInQueryData as findPostInNotifsQueryData} from './notifications/feed' import {precacheThreadPosts as precacheResolvedUris} from './resolve-uri' @@ -65,7 +64,6 @@ export type ThreadNode = export function usePostThreadQuery(uri: string | undefined) { const queryClient = useQueryClient() return useQuery<ThreadNode, Error>({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(uri || ''), async queryFn() { const res = await getAgent().getPostThread({uri: uri!}) diff --git a/src/state/queries/post.ts b/src/state/queries/post.ts index d4193b8ce..b31696446 100644 --- a/src/state/queries/post.ts +++ b/src/state/queries/post.ts @@ -4,13 +4,11 @@ import {useQuery, useMutation, useQueryClient} from '@tanstack/react-query' import {getAgent} from '#/state/session' import {updatePostShadow} from '#/state/cache/post-shadow' -import {STALE} from '#/state/queries' export const RQKEY = (postUri: string) => ['post', postUri] export function usePostQuery(uri: string | undefined) { return useQuery<AppBskyFeedDefs.PostView>({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(uri || ''), async queryFn() { const res = await getAgent().getPosts({uris: [uri!]}) @@ -29,7 +27,6 @@ export function useGetPost() { return React.useCallback( async ({uri}: {uri: string}) => { return queryClient.fetchQuery({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(uri || ''), async queryFn() { const urip = new AtUri(uri) diff --git a/src/state/queries/profile-feedgens.ts b/src/state/queries/profile-feedgens.ts index 04860430e..7d33eb9c8 100644 --- a/src/state/queries/profile-feedgens.ts +++ b/src/state/queries/profile-feedgens.ts @@ -2,7 +2,6 @@ import {AppBskyFeedGetActorFeeds} from '@atproto/api' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' import {getAgent} from '#/state/session' -import {STALE} from '#/state/queries' const PAGE_SIZE = 30 type RQPageParam = string | undefined @@ -22,7 +21,6 @@ export function useProfileFeedgensQuery( QueryKey, RQPageParam >({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(did), async queryFn({pageParam}: {pageParam: RQPageParam}) { const res = await getAgent().app.bsky.feed.getActorFeeds({ diff --git a/src/state/queries/profile-followers.ts b/src/state/queries/profile-followers.ts index 774bd23f1..b2008851d 100644 --- a/src/state/queries/profile-followers.ts +++ b/src/state/queries/profile-followers.ts @@ -2,7 +2,6 @@ import {AppBskyGraphGetFollowers} from '@atproto/api' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' import {getAgent} from '#/state/session' -import {STALE} from '#/state/queries' const PAGE_SIZE = 30 type RQPageParam = string | undefined @@ -17,7 +16,6 @@ export function useProfileFollowersQuery(did: string | undefined) { QueryKey, RQPageParam >({ - staleTime: STALE.MINUTES.FIVE, queryKey: RQKEY(did || ''), async queryFn({pageParam}: {pageParam: RQPageParam}) { const res = await getAgent().app.bsky.graph.getFollowers({ diff --git a/src/state/queries/profile-lists.ts b/src/state/queries/profile-lists.ts index 997c85910..505d33b9f 100644 --- a/src/state/queries/profile-lists.ts +++ b/src/state/queries/profile-lists.ts @@ -1,8 +1,6 @@ import {AppBskyGraphGetLists} from '@atproto/api' import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' - import {getAgent} from '#/state/session' -import {STALE} from '#/state/queries' const PAGE_SIZE = 30 type RQPageParam = string | undefined @@ -18,7 +16,6 @@ export function useProfileListsQuery(did: string, opts?: {enabled?: boolean}) { QueryKey, RQPageParam >({ - staleTime: STALE.MINUTES.ONE, queryKey: RQKEY(did), async queryFn({pageParam}: {pageParam: RQPageParam}) { const res = await getAgent().app.bsky.graph.getLists({ diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index 9467a2553..62e8f39c0 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -21,6 +21,10 @@ export const RQKEY = (did: string) => ['profile', did] export function useProfileQuery({did}: {did: string | undefined}) { return useQuery({ + // WARNING + // this staleTime is load-bearing + // if you remove it, the UI infinite-loops + // -prf staleTime: STALE.MINUTES.FIVE, queryKey: RQKEY(did || ''), queryFn: async () => { diff --git a/src/state/queries/resolve-uri.ts b/src/state/queries/resolve-uri.ts index 05a9f4b1c..a75998466 100644 --- a/src/state/queries/resolve-uri.ts +++ b/src/state/queries/resolve-uri.ts @@ -23,7 +23,7 @@ export function useResolveUriQuery(uri: string | undefined): UriUseQueryResult { export function useResolveDidQuery(didOrHandle: string | undefined) { return useQuery<string, Error>({ - staleTime: STALE.INFINITY, + staleTime: STALE.HOURS.ONE, queryKey: RQKEY(didOrHandle || ''), async queryFn() { if (!didOrHandle) { diff --git a/src/state/queries/service.ts b/src/state/queries/service.ts index c7df89960..5f7e10778 100644 --- a/src/state/queries/service.ts +++ b/src/state/queries/service.ts @@ -1,13 +1,10 @@ import {BskyAgent} from '@atproto/api' import {useQuery} from '@tanstack/react-query' -import {STALE} from '#/state/queries' - export const RQKEY = (serviceUrl: string) => ['service', serviceUrl] export function useServiceQuery(serviceUrl: string) { return useQuery({ - staleTime: STALE.HOURS.ONE, queryKey: RQKEY(serviceUrl), queryFn: async () => { const agent = new BskyAgent({service: serviceUrl}) diff --git a/src/state/queries/suggested-follows.ts b/src/state/queries/suggested-follows.ts index 176bbe15b..eadcb590a 100644 --- a/src/state/queries/suggested-follows.ts +++ b/src/state/queries/suggested-follows.ts @@ -90,7 +90,7 @@ export function useGetSuggestedFollowersByActor() { return React.useCallback( async (actor: string) => { const res = await queryClient.fetchQuery({ - staleTime: 60 * 1000, + staleTime: STALE.MINUTES.ONE, queryKey: suggestedFollowsByActorQueryKey(actor), queryFn: async () => { const res = |