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/util.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/util.ts')
-rw-r--r-- | src/state/queries/util.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/state/queries/util.ts b/src/state/queries/util.ts index b74893fcd..f733c3788 100644 --- a/src/state/queries/util.ts +++ b/src/state/queries/util.ts @@ -1,8 +1,10 @@ import { + AppBskyActorDefs, AppBskyEmbedRecord, AppBskyEmbedRecordWithMedia, AppBskyFeedDefs, AppBskyFeedPost, + AtUri, } from '@atproto/api' import {InfiniteData, QueryClient, QueryKey} from '@tanstack/react-query' @@ -22,6 +24,23 @@ export function truncateAndInvalidate<T = any>( queryClient.invalidateQueries({queryKey}) } +// Given an AtUri, this function will check if the AtUri matches a +// hit regardless of whether the AtUri uses a DID or handle as a host. +// +// AtUri should be the URI that is being searched for, while currentUri +// is the URI that is being checked. currentAuthor is the author +// of the currentUri that is being checked. +export function didOrHandleUriMatches( + atUri: AtUri, + record: {uri: string; author: AppBskyActorDefs.ProfileViewBasic}, +) { + if (atUri.host.startsWith('did:')) { + return atUri.href === record.uri + } + + return atUri.host === record.author.handle && record.uri.endsWith(atUri.rkey) +} + export function getEmbeddedPost( v: unknown, ): AppBskyEmbedRecord.ViewRecord | undefined { |