about summary refs log tree commit diff
path: root/src/state/queries/threadgate/index.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-08-23 14:35:48 -0500
committerGitHub <noreply@github.com>2024-08-23 12:35:48 -0700
commit425dd5f27feade1abff7a8e882929ca112376210 (patch)
tree4a279fe3f60b65a6f5c9774adb6e4d36ba1b046f /src/state/queries/threadgate/index.ts
parent5ec8761b294b6a650af9ee286df6864d6fc4f25d (diff)
downloadvoidsky-425dd5f27feade1abff7a8e882929ca112376210.tar.zst
Optimistic hidden replies (#4977)
Diffstat (limited to 'src/state/queries/threadgate/index.ts')
-rw-r--r--src/state/queries/threadgate/index.ts19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/state/queries/threadgate/index.ts b/src/state/queries/threadgate/index.ts
index faa166e2c..8aa932081 100644
--- a/src/state/queries/threadgate/index.ts
+++ b/src/state/queries/threadgate/index.ts
@@ -9,12 +9,10 @@ import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
 
 import {networkRetry, retry} from '#/lib/async/retry'
 import {until} from '#/lib/async/until'
-import {updatePostShadow} from '#/state/cache/post-shadow'
 import {STALE} from '#/state/queries'
 import {RQKEY_ROOT as postThreadQueryKeyRoot} from '#/state/queries/post-thread'
 import {ThreadgateAllowUISetting} from '#/state/queries/threadgate/types'
 import {
-  createTempThreadgateView,
   createThreadgateRecord,
   mergeThreadgateRecords,
   threadgateAllowUISettingToAllowRecordValue,
@@ -33,18 +31,16 @@ export const createThreadgateRecordQueryKey = (uri: string) => [
 ]
 
 export function useThreadgateRecordQuery({
-  enabled,
   postUri,
   initialData,
 }: {
-  enabled?: boolean
   postUri?: string
   initialData?: AppBskyFeedThreadgate.Record
 } = {}) {
   const agent = useAgent()
 
   return useQuery({
-    enabled: enabled ?? !!postUri,
+    enabled: !!postUri,
     queryKey: createThreadgateRecordQueryKey(postUri || ''),
     placeholderData: initialData,
     staleTime: STALE.MINUTES.ONE,
@@ -344,26 +340,17 @@ export function useToggleReplyVisibilityMutation() {
         }
       })
     },
-    onSuccess(_, {postUri, replyUri}) {
-      updatePostShadow(queryClient, postUri, {
-        threadgateView: createTempThreadgateView({
-          postUri,
-          hiddenReplies: [replyUri],
-        }),
-      })
+    onSuccess() {
       queryClient.invalidateQueries({
         queryKey: [threadgateRecordQueryKeyRoot],
       })
     },
-    onError(_, {postUri, replyUri, action}) {
+    onError(_, {replyUri, action}) {
       if (action === 'hide') {
         hiddenReplies.removeHiddenReplyUri(replyUri)
       } else if (action === 'show') {
         hiddenReplies.addHiddenReplyUri(replyUri)
       }
-      updatePostShadow(queryClient, postUri, {
-        threadgateView: undefined,
-      })
     },
   })
 }