[🐴] Block states, read only (#4022)
* Refactor ChatListItem for mod state * Refactor Conversation Header for mod state * Invalidate query for list when blocking/unblocking * Remove unused prop, restore border * Add mutations, hook up profile shadow to list query, use shadow-aware query for convo (#4024)
This commit is contained in:
parent
d390db0fa2
commit
6efe90a5f5
6 changed files with 250 additions and 73 deletions
2
src/state/cache/profile-shadow.ts
vendored
2
src/state/cache/profile-shadow.ts
vendored
|
@ -6,6 +6,7 @@ import EventEmitter from 'eventemitter3'
|
|||
import {batchedUpdates} from '#/lib/batchedUpdates'
|
||||
import {findAllProfilesInQueryData as findAllProfilesInActorSearchQueryData} from '../queries/actor-search'
|
||||
import {findAllProfilesInQueryData as findAllProfilesInListMembersQueryData} from '../queries/list-members'
|
||||
import {findAllProfilesInQueryData as findAllProfilesInListConvosQueryData} from '../queries/messages/list-converations'
|
||||
import {findAllProfilesInQueryData as findAllProfilesInMyBlockedAccountsQueryData} from '../queries/my-blocked-accounts'
|
||||
import {findAllProfilesInQueryData as findAllProfilesInMyMutedAccountsQueryData} from '../queries/my-muted-accounts'
|
||||
import {findAllProfilesInQueryData as findAllProfilesInPostLikedByQueryData} from '../queries/post-liked-by'
|
||||
|
@ -105,4 +106,5 @@ function* findProfilesInCache(
|
|||
yield* findAllProfilesInProfileFollowsQueryData(queryClient, did)
|
||||
yield* findAllProfilesInSuggestedFollowsQueryData(queryClient, did)
|
||||
yield* findAllProfilesInActorSearchQueryData(queryClient, did)
|
||||
yield* findAllProfilesInListConvosQueryData(queryClient, did)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import {useCallback, useMemo} from 'react'
|
||||
import {ChatBskyConvoDefs, ChatBskyConvoListConvos} from '@atproto/api'
|
||||
import {useInfiniteQuery, useQueryClient} from '@tanstack/react-query'
|
||||
import {
|
||||
InfiniteData,
|
||||
QueryClient,
|
||||
useInfiniteQuery,
|
||||
useQueryClient,
|
||||
} from '@tanstack/react-query'
|
||||
|
||||
import {useCurrentConvoId} from '#/state/messages/current-convo-id'
|
||||
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
|
||||
|
@ -140,3 +145,29 @@ function optimisticUpdate(
|
|||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export function* findAllProfilesInQueryData(
|
||||
queryClient: QueryClient,
|
||||
did: string,
|
||||
) {
|
||||
const queryDatas = queryClient.getQueriesData<
|
||||
InfiniteData<ChatBskyConvoListConvos.OutputSchema>
|
||||
>({
|
||||
queryKey: RQKEY,
|
||||
})
|
||||
for (const [_queryKey, queryData] of queryDatas) {
|
||||
if (!queryData?.pages) {
|
||||
continue
|
||||
}
|
||||
|
||||
for (const page of queryData.pages) {
|
||||
for (const convo of page.convos) {
|
||||
for (const member of convo.members) {
|
||||
if (member.did === did) {
|
||||
yield member
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue