Skeletonize account UI while metadata is loading

While the kind-0 metadata query for logged-in accounts is in flight, we
were rendering the genUserName-derived animal name (and its first
letter as the avatar fallback) before falling back to the real display
name once the profile arrived. That made the AccountSwitcher trigger
flash a meaningless 'Brave Otter' / 'B' before settling on the real
identity.

Expose isLoading from useLoggedInAccounts and, while it is still true
and we have no metadata.name yet, render Skeletons in place of:
  - the avatar fallback letter (in the AccountSwitcher trigger and the
    other-accounts dropdown rows),
  - the displayed name in the dropdown rows.

Once the query settles, behavior is unchanged: a real name renders if
present, otherwise the genUserName fallback fills in.
This commit is contained in:
Alex Gleason committed 2026-05-11 18:16:59 -05:00
1 parent 2357913037
commit 3f69f84d19
2 files changed
+52 -21

No files matched your search

+2 -1
View File
@@ -14,7 +14,7 @@ export function useLoggedInAccounts() {
const { nostr } = useNostr();
const { logins, setLogin, removeLogin } = useNostrLogin();
const { data: authors = [] } = useQuery({
const { data: authors = [], isLoading } = useQuery({
queryKey: ['nostr', 'logins', logins.map((l) => l.id).join(';')],
queryFn: async () => {
const events = await nostr.query(
@@ -50,6 +50,7 @@ export function useLoggedInAccounts() {
authors,
currentUser,
otherUsers,
isLoading,
setLogin,
removeLogin,
};