Bluesky app fork with some witchin' additions ๐Ÿ’ซ
0
fork

Configure Feed

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

[๐Ÿด] Invalidate list convos query on block (#4171)

* more memoization

* invalidate listconvos query on block

authored by

Samuel Newman and committed by
GitHub
3ca41e4e b9373723

+22 -18
+20 -18
src/state/queries/messages/list-converations.ts
··· 46 46 }) 47 47 const moderationOpts = useModerationOpts() 48 48 49 - const count = 50 - convos.data?.pages 51 - .flatMap(page => page.convos) 52 - .filter(convo => convo.id !== currentConvoId) 53 - .reduce((acc, convo) => { 54 - const otherMember = convo.members.find( 55 - member => member.did !== currentAccount?.did, 56 - ) 49 + const count = useMemo(() => { 50 + return ( 51 + convos.data?.pages 52 + .flatMap(page => page.convos) 53 + .filter(convo => convo.id !== currentConvoId) 54 + .reduce((acc, convo) => { 55 + const otherMember = convo.members.find( 56 + member => member.did !== currentAccount?.did, 57 + ) 57 58 58 - if (!otherMember || !moderationOpts) return acc 59 + if (!otherMember || !moderationOpts) return acc 59 60 60 - // TODO could shadow this outside this hook and get optimistic block state 61 - const moderation = moderateProfile(otherMember, moderationOpts) 62 - const shouldIgnore = 63 - convo.muted || 64 - moderation.blocked || 65 - otherMember.did === 'missing.invalid' 66 - const unreadCount = !shouldIgnore && convo.unreadCount > 0 ? 1 : 0 61 + const moderation = moderateProfile(otherMember, moderationOpts) 62 + const shouldIgnore = 63 + convo.muted || 64 + moderation.blocked || 65 + otherMember.did === 'missing.invalid' 66 + const unreadCount = !shouldIgnore && convo.unreadCount > 0 ? 1 : 0 67 67 68 - return acc + unreadCount 69 - }, 0) ?? 0 68 + return acc + unreadCount 69 + }, 0) ?? 0 70 + ) 71 + }, [convos.data, currentAccount?.did, currentConvoId, moderationOpts]) 70 72 71 73 return useMemo(() => { 72 74 return {
+2
src/state/queries/profile.ts
··· 25 25 import {resetProfilePostsQueries} from '#/state/queries/post-feed' 26 26 import {updateProfileShadow} from '../cache/profile-shadow' 27 27 import {useAgent, useSession} from '../session' 28 + import {RQKEY as RQKEY_LIST_CONVOS} from './messages/list-converations' 28 29 import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts' 29 30 import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts' 30 31 ··· 414 415 updateProfileShadow(queryClient, did, { 415 416 blockingUri: finalBlockingUri, 416 417 }) 418 + queryClient.invalidateQueries({queryKey: RQKEY_LIST_CONVOS}) 417 419 }, 418 420 }) 419 421