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
|
|
@ -2,6 +2,7 @@ import {
|
|||
AppBskyActorDefs,
|
||||
AppBskyFeedDefs,
|
||||
AppBskyFeedSearchPosts,
|
||||
AtUri,
|
||||
} from '@atproto/api'
|
||||
import {
|
||||
InfiniteData,
|
||||
|
|
@ -11,7 +12,11 @@ import {
|
|||
} from '@tanstack/react-query'
|
||||
|
||||
import {useAgent} from '#/state/session'
|
||||
import {embedViewRecordToPostView, getEmbeddedPost} from './util'
|
||||
import {
|
||||
didOrHandleUriMatches,
|
||||
embedViewRecordToPostView,
|
||||
getEmbeddedPost,
|
||||
} from './util'
|
||||
|
||||
const searchPostsQueryKeyRoot = 'search-posts'
|
||||
const searchPostsQueryKey = ({query, sort}: {query: string; sort?: string}) => [
|
||||
|
|
@ -62,17 +67,20 @@ export function* findAllPostsInQueryData(
|
|||
>({
|
||||
queryKey: [searchPostsQueryKeyRoot],
|
||||
})
|
||||
const atUri = new AtUri(uri)
|
||||
|
||||
for (const [_queryKey, queryData] of queryDatas) {
|
||||
if (!queryData?.pages) {
|
||||
continue
|
||||
}
|
||||
for (const page of queryData?.pages) {
|
||||
for (const post of page.posts) {
|
||||
if (post.uri === uri) {
|
||||
if (didOrHandleUriMatches(atUri, post)) {
|
||||
yield post
|
||||
}
|
||||
|
||||
const quotedPost = getEmbeddedPost(post.embed)
|
||||
if (quotedPost?.uri === uri) {
|
||||
if (quotedPost && didOrHandleUriMatches(atUri, quotedPost)) {
|
||||
yield embedViewRecordToPostView(quotedPost)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue