remove resolution from post thread (#4297)
* remove resolution from post thread
nit
completely remove did cache lookup
move cache check for did to `usePostThreadQuery`
remove resolution from post thread
* helper function
* simplify
* simplify search too
* fix missing check for root or parent quoted post 🤯
* fix thread traversal
This commit is contained in:
parent
21d4d5f600
commit
8d8323421c
6 changed files with 112 additions and 65 deletions
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import {useEffect, useRef} from 'react'
|
||||
import {AppBskyActorDefs, AppBskyFeedDefs} from '@atproto/api'
|
||||
import {AppBskyActorDefs, AppBskyFeedDefs, AtUri} from '@atproto/api'
|
||||
import {
|
||||
InfiniteData,
|
||||
QueryClient,
|
||||
|
|
@ -30,7 +30,11 @@ import {useMutedThreads} from '#/state/muted-threads'
|
|||
import {useAgent} from '#/state/session'
|
||||
import {useModerationOpts} from '../../preferences/moderation-opts'
|
||||
import {STALE} from '..'
|
||||
import {embedViewRecordToPostView, getEmbeddedPost} from '../util'
|
||||
import {
|
||||
didOrHandleUriMatches,
|
||||
embedViewRecordToPostView,
|
||||
getEmbeddedPost,
|
||||
} from '../util'
|
||||
import {FeedPage} from './types'
|
||||
import {useUnreadNotificationsApi} from './unread'
|
||||
import {fetchPage} from './util'
|
||||
|
|
@ -142,6 +146,8 @@ export function* findAllPostsInQueryData(
|
|||
queryClient: QueryClient,
|
||||
uri: string,
|
||||
): Generator<AppBskyFeedDefs.PostView, void> {
|
||||
const atUri = new AtUri(uri)
|
||||
|
||||
const queryDatas = queryClient.getQueriesData<InfiniteData<FeedPage>>({
|
||||
queryKey: [RQKEY_ROOT],
|
||||
})
|
||||
|
|
@ -149,14 +155,16 @@ export function* findAllPostsInQueryData(
|
|||
if (!queryData?.pages) {
|
||||
continue
|
||||
}
|
||||
|
||||
for (const page of queryData?.pages) {
|
||||
for (const item of page.items) {
|
||||
if (item.subject?.uri === uri) {
|
||||
if (item.subject && didOrHandleUriMatches(atUri, item.subject)) {
|
||||
yield item.subject
|
||||
}
|
||||
|
||||
const quotedPost = getEmbeddedPost(item.subject?.embed)
|
||||
if (quotedPost?.uri === uri) {
|
||||
yield embedViewRecordToPostView(quotedPost)
|
||||
if (quotedPost && didOrHandleUriMatches(atUri, quotedPost)) {
|
||||
yield embedViewRecordToPostView(quotedPost!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue