From 1904a541319af1f8e5d5f5dd3e495c47784557f5 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Thu, 1 Jan 2026 21:24:06 +0100 Subject: [PATCH] fix(nostr-feed): Fetch profiles for submission authors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add watchers to fetch profiles when submissions and comments load, ensuring display names are shown instead of pubkeys. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../components/SubmissionDetail.vue | 35 ++++++++++++++++--- .../nostr-feed/components/SubmissionList.vue | 12 +++++-- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/modules/nostr-feed/components/SubmissionDetail.vue b/src/modules/nostr-feed/components/SubmissionDetail.vue index a4f2819..48a9068 100644 --- a/src/modules/nostr-feed/components/SubmissionDetail.vue +++ b/src/modules/nostr-feed/components/SubmissionDetail.vue @@ -4,7 +4,7 @@ * Displays complete submission content and threaded comments */ -import { ref, computed } from 'vue' +import { ref, computed, watch } from 'vue' import { useRoute, useRouter } from 'vue-router' import { formatDistanceToNow } from 'date-fns' import { @@ -85,9 +85,7 @@ const currentUserPubkey = computed(() => authService?.user?.value?.pubkey || nul // Get display name for a pubkey function getDisplayName(pubkey: string): string { if (profileService) { - const profile = profileService.getProfile(pubkey) - if (profile?.display_name) return profile.display_name - if (profile?.name) return profile.name + return profileService.getDisplayName(pubkey) } return `${pubkey.slice(0, 8)}...` } @@ -203,7 +201,7 @@ async function submitComment() { await submissionService.createComment( props.submissionId, commentText.value.trim(), - null // Top-level comment + undefined // Top-level comment ) cancelReply() } catch (err: any) { @@ -260,6 +258,33 @@ function countReplies(comment: SubmissionCommentType): number { function goBack() { router.back() } + +// Helper to collect all pubkeys from comments recursively +function collectCommentPubkeys(comments: SubmissionCommentType[]): string[] { + const pubkeys: string[] = [] + for (const comment of comments) { + pubkeys.push(comment.pubkey) + if (comment.replies?.length) { + pubkeys.push(...collectCommentPubkeys(comment.replies)) + } + } + return pubkeys +} + +// Fetch profiles when submission loads +watch(submission, (sub) => { + if (profileService && sub) { + profileService.fetchProfiles([sub.pubkey]) + } +}, { immediate: true }) + +// Fetch profiles when comments load +watch(comments, (newComments) => { + if (profileService && newComments.length > 0) { + const pubkeys = [...new Set(collectCommentPubkeys(newComments))] + profileService.fetchProfiles(pubkeys) + } +}, { immediate: true })