about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/state/cache/post-shadow.ts12
-rw-r--r--src/state/queries/profile.ts4
2 files changed, 13 insertions, 3 deletions
diff --git a/src/state/cache/post-shadow.ts b/src/state/cache/post-shadow.ts
index 923e5c000..3f9644879 100644
--- a/src/state/cache/post-shadow.ts
+++ b/src/state/cache/post-shadow.ts
@@ -14,6 +14,7 @@ import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from '#/state/qu
 import {findAllPostsInQueryData as findAllPostsInQuoteQueryData} from '#/state/queries/post-quotes'
 import {findAllPostsInQueryData as findAllPostsInThreadQueryData} from '#/state/queries/post-thread'
 import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from '#/state/queries/search-posts'
+import {useProfileShadow} from './profile-shadow'
 import {castAsShadow, type Shadow} from './types'
 export type {Shadow} from './types'
 
@@ -43,6 +44,10 @@ export function usePostShadow(
     setShadow(shadows.get(post))
   }
 
+  const authorShadow = useProfileShadow(post.author)
+  const wasMuted = !!authorShadow.viewer?.muted
+  const wasBlocked = !!authorShadow.viewer?.blocking
+
   useEffect(() => {
     function onUpdate() {
       setShadow(shadows.get(post))
@@ -54,15 +59,18 @@ export function usePostShadow(
   }, [post, setShadow])
 
   return useMemo(() => {
+    if (wasMuted || wasBlocked) {
+      return POST_TOMBSTONE
+    }
     if (shadow) {
       return mergeShadow(post, shadow)
     } else {
       return castAsShadow(post)
     }
-  }, [post, shadow])
+  }, [post, shadow, wasMuted, wasBlocked])
 }
 
-function mergeShadow(
+export function mergeShadow(
   post: AppBskyFeedDefs.PostView,
   shadow: Partial<PostShadow>,
 ): Shadow<AppBskyFeedDefs.PostView> | typeof POST_TOMBSTONE {
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts
index eb65fef7c..b0af57c4a 100644
--- a/src/state/queries/profile.ts
+++ b/src/state/queries/profile.ts
@@ -499,9 +499,10 @@ function useProfileBlockMutation() {
         {subject: did, createdAt: new Date().toISOString()},
       )
     },
-    onSuccess(_, {did}) {
+    onSuccess(data, {did}) {
       queryClient.invalidateQueries({queryKey: RQKEY_MY_BLOCKED()})
       resetProfilePostsQueries(queryClient, did, 1000)
+      updateProfileShadow(queryClient, did, {blockingUri: data.uri})
     },
   })
 }
@@ -523,6 +524,7 @@ function useProfileUnblockMutation() {
     },
     onSuccess(_, {did}) {
       resetProfilePostsQueries(queryClient, did, 1000)
+      updateProfileShadow(queryClient, did, {blockingUri: undefined})
     },
   })
 }