From ac2799408352ce5d6d0aaf9a48eadb8ede17cb73 Mon Sep 17 00:00:00 2001 From: npub1cc3ha7z055mu0rwwu7806t2wt8mj3pvu0uv5mfp2c50dahaqhczshdalg6 Date: Fri, 19 Jun 2026 10:26:03 -0400 Subject: [PATCH] Fix display names flashing to pubkeys when loading older messages useUsersBatchQuery's queryKey includes the full sorted pubkey list, so loading older history (which adds new authors) changes the key and starts a brand-new query with no data, even though most of those profiles are already cached. Until the new batch resolves, resolveUserLabel falls back to the truncated pubkey for every author, not just the new ones. Add placeholderData: keepPreviousData so the previous batch's resolved names keep rendering while the larger batch refetches in the background. Co-authored-by: Tyler Longwell Signed-off-by: Tyler Longwell --- desktop/src/features/profile/hooks.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/desktop/src/features/profile/hooks.ts b/desktop/src/features/profile/hooks.ts index 9f1eca8bf0..4c4f86143b 100644 --- a/desktop/src/features/profile/hooks.ts +++ b/desktop/src/features/profile/hooks.ts @@ -1,5 +1,10 @@ import * as React from "react"; -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { + keepPreviousData, + useMutation, + useQuery, + useQueryClient, +} from "@tanstack/react-query"; import { getProfile, @@ -281,6 +286,10 @@ export function useUsersBatchQuery( enabled, queryKey: ["users-batch", ...normalizedPubkeys], queryFn: () => getUsersBatch(normalizedPubkeys), + // Loading older messages grows the pubkey set, which changes this query's + // key entirely. Without this, already-resolved authors would flash back + // to their raw pubkey while the larger batch refetches. + placeholderData: keepPreviousData, staleTime: 60_000, gcTime: 5 * 60 * 1_000, });