diff options
author | Hailey <me@haileyok.com> | 2024-02-08 17:38:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-09 01:38:16 +0000 |
commit | de28626001a3685753b0b4ca33b0a16c66ecf204 (patch) | |
tree | 1f48f31126acd9674d01aed60ff22a5b170e4a31 /src/state/queries/post-thread.ts | |
parent | d9b62955b5424046b19fe4b8761f820774656f3f (diff) | |
download | voidsky-de28626001a3685753b0b4ca33b0a16c66ecf204.tar.zst |
Precache basic profile from posts for instant future navigations (#2795)
* skeleton for caching * modify some existing logic * refactor uri resolution query * add precache feed posts * adjustments * remove prefetch on hover (maybe revert, just example) * fix * change arg name to match what we want * optional infinite stale time * use `ProfileViewDetailed` * Revert "remove prefetch on hover (maybe revert, just example)" This reverts commit 08609deb0defa7cea040438bc37dd3488ddc56f4. * add warning comment back for stale time * remove comment * store profile with both the handle and did for query key * remove extra block from revert * clarify argument name * remove QT cache * structure queries the same (put `enabled` at bottom) * use both `ProfileViewDetailed` and `ProfileView` for the query return type * placeholder profile header * remove logs * remove a few other things we don't need * add placeholder * refactor * refactor * we don't need this height adjustment now * use gray banner while loading * set background color of image to the loading placeholder color * reorg imports * add border to header on loading * Fix style * Rm radius * oops * Undo edit * Back out type changes * Tighten some types and moderate shadow * Move precaching fns to profile where the cache is * Rename functions to match what they do now * Remove anys --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/state/queries/post-thread.ts')
-rw-r--r-- | src/state/queries/post-thread.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/state/queries/post-thread.ts b/src/state/queries/post-thread.ts index abb0fea11..ba4243163 100644 --- a/src/state/queries/post-thread.ts +++ b/src/state/queries/post-thread.ts @@ -10,7 +10,7 @@ import {getAgent} from '#/state/session' import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types' import {findPostInQueryData as findPostInFeedQueryData} from './post-feed' import {findPostInQueryData as findPostInNotifsQueryData} from './notifications/feed' -import {precacheThreadPosts as precacheResolvedUris} from './resolve-uri' +import {precacheThreadPostProfiles} from './profile' import {getEmbeddedPost} from './util' export const RQKEY = (uri: string) => ['post-thread', uri] @@ -71,7 +71,7 @@ export function usePostThreadQuery(uri: string | undefined) { const res = await getAgent().getPostThread({uri: uri!}) if (res.success) { const nodes = responseToThreadNodes(res.data.thread) - precacheResolvedUris(queryClient, nodes) // precache the handle->did resolution + precacheThreadPostProfiles(queryClient, nodes) return nodes } return {type: 'unknown', uri: uri!} |