diff options
author | Hailey <me@haileyok.com> | 2024-06-03 15:58:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 23:58:16 +0100 |
commit | 8d8323421c5f9c9f850f2b4e6fd4c62b932e14b2 (patch) | |
tree | f6628760b67a9ad371b847c83ba7a8546d0675ba /src/state/queries/search-posts.ts | |
parent | 21d4d5f6009ead7729543c2e587ea88bdaa00a87 (diff) | |
download | voidsky-8d8323421c5f9c9f850f2b4e6fd4c62b932e14b2.tar.zst |
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
Diffstat (limited to 'src/state/queries/search-posts.ts')
-rw-r--r-- | src/state/queries/search-posts.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/state/queries/search-posts.ts b/src/state/queries/search-posts.ts index f71d64255..5c50ad267 100644 --- a/src/state/queries/search-posts.ts +++ b/src/state/queries/search-posts.ts @@ -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) } } |