diff options
author | Eric Bailey <git@esb.lol> | 2024-08-23 14:35:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-23 12:35:48 -0700 |
commit | 425dd5f27feade1abff7a8e882929ca112376210 (patch) | |
tree | 4a279fe3f60b65a6f5c9774adb6e4d36ba1b046f /src/state/queries/post-thread.ts | |
parent | 5ec8761b294b6a650af9ee286df6864d6fc4f25d (diff) | |
download | voidsky-425dd5f27feade1abff7a8e882929ca112376210.tar.zst |
Optimistic hidden replies (#4977)
Diffstat (limited to 'src/state/queries/post-thread.ts')
-rw-r--r-- | src/state/queries/post-thread.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/state/queries/post-thread.ts b/src/state/queries/post-thread.ts index 2c4a36c01..9d650024a 100644 --- a/src/state/queries/post-thread.ts +++ b/src/state/queries/post-thread.ts @@ -88,7 +88,10 @@ export type ThreadModerationCache = WeakMap<ThreadNode, ModerationDecision> export function usePostThreadQuery(uri: string | undefined) { const queryClient = useQueryClient() const agent = useAgent() - return useQuery<ThreadNode, Error>({ + return useQuery< + {thread: ThreadNode; threadgate?: AppBskyFeedDefs.ThreadgateView}, + Error + >({ gcTime: 0, queryKey: RQKEY(uri || ''), async queryFn() { @@ -99,16 +102,21 @@ export function usePostThreadQuery(uri: string | undefined) { if (res.success) { const thread = responseToThreadNodes(res.data.thread) annotateSelfThread(thread) - return thread + return { + thread, + threadgate: res.data.threadgate as + | AppBskyFeedDefs.ThreadgateView + | undefined, + } } - return {type: 'unknown', uri: uri!} + return {thread: {type: 'unknown', uri: uri!}} }, enabled: !!uri, placeholderData: () => { if (!uri) return const post = findPostInQueryData(queryClient, uri) if (post) { - return post + return {thread: post} } return undefined }, |