Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Instant Feed Update on Mute or Moderation Action (#8463)

* Implemented #2406: Instant Feed Update on Mute or Moderation Action
Posts from muted or blocked users are now removed immediately from
the feed. This is achieved by extending the usePostShadow hook to
check if the post author is muted or blocked and return
POST_TOMBSTONE accordingly.
A unit test was also added to validate the new logic.

Co-authored-by: Pedro Macedo <pedrosantosmacedo@tecnico.ulisboa.pt>

* remove useless tests

---------

Co-authored-by: Pedro Macedo <pedrosantosmacedo@tecnico.ulisboa.pt>
Co-authored-by: Samuel Newman <mozzius@protonmail.com>

authored by

Francisco Nascimento
Pedro Macedo
Samuel Newman
and committed by
GitHub
26910537 1380c5ac

+13 -3
+10 -2
src/state/cache/post-shadow.ts
··· 14 14 import {findAllPostsInQueryData as findAllPostsInQuoteQueryData} from '#/state/queries/post-quotes' 15 15 import {findAllPostsInQueryData as findAllPostsInThreadQueryData} from '#/state/queries/post-thread' 16 16 import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from '#/state/queries/search-posts' 17 + import {useProfileShadow} from './profile-shadow' 17 18 import {castAsShadow, type Shadow} from './types' 18 19 export type {Shadow} from './types' 19 20 ··· 43 44 setShadow(shadows.get(post)) 44 45 } 45 46 47 + const authorShadow = useProfileShadow(post.author) 48 + const wasMuted = !!authorShadow.viewer?.muted 49 + const wasBlocked = !!authorShadow.viewer?.blocking 50 + 46 51 useEffect(() => { 47 52 function onUpdate() { 48 53 setShadow(shadows.get(post)) ··· 54 59 }, [post, setShadow]) 55 60 56 61 return useMemo(() => { 62 + if (wasMuted || wasBlocked) { 63 + return POST_TOMBSTONE 64 + } 57 65 if (shadow) { 58 66 return mergeShadow(post, shadow) 59 67 } else { 60 68 return castAsShadow(post) 61 69 } 62 - }, [post, shadow]) 70 + }, [post, shadow, wasMuted, wasBlocked]) 63 71 } 64 72 65 - function mergeShadow( 73 + export function mergeShadow( 66 74 post: AppBskyFeedDefs.PostView, 67 75 shadow: Partial<PostShadow>, 68 76 ): Shadow<AppBskyFeedDefs.PostView> | typeof POST_TOMBSTONE {
+3 -1
src/state/queries/profile.ts
··· 499 499 {subject: did, createdAt: new Date().toISOString()}, 500 500 ) 501 501 }, 502 - onSuccess(_, {did}) { 502 + onSuccess(data, {did}) { 503 503 queryClient.invalidateQueries({queryKey: RQKEY_MY_BLOCKED()}) 504 504 resetProfilePostsQueries(queryClient, did, 1000) 505 + updateProfileShadow(queryClient, did, {blockingUri: data.uri}) 505 506 }, 506 507 }) 507 508 } ··· 523 524 }, 524 525 onSuccess(_, {did}) { 525 526 resetProfilePostsQueries(queryClient, did, 1000) 527 + updateProfileShadow(queryClient, did, {blockingUri: undefined}) 526 528 }, 527 529 }) 528 530 }