diff --git a/src/app.ts b/src/app.ts index ccfed43..459283e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -63,12 +63,6 @@ export async function createAppInstance() { component: () => import('./pages/Login.vue'), meta: { requiresAuth: false } }, - { - path: '/link-aggregator-test', - name: 'link-aggregator-test', - component: () => import('./pages/LinkAggregatorTest.vue'), - meta: { requiresAuth: false } - }, // Pre-register module routes ...moduleRoutes ] diff --git a/src/modules/nostr-feed/components/SubmissionComment.vue b/src/modules/nostr-feed/components/SubmissionComment.vue index 9a5f6d4..ab52a9e 100644 --- a/src/modules/nostr-feed/components/SubmissionComment.vue +++ b/src/modules/nostr-feed/components/SubmissionComment.vue @@ -6,8 +6,7 @@ import { computed, ref } from 'vue' import { formatDistanceToNow } from 'date-fns' -import { ChevronUp, ChevronDown, Reply, Flag, MoreHorizontal, Send, X } from 'lucide-vue-next' -import VoteControls from './VoteControls.vue' +import { ChevronUp, ChevronDown, Reply, Flag, MoreHorizontal, Send } from 'lucide-vue-next' import type { SubmissionComment as CommentType } from '../types/submission' interface Props { diff --git a/src/modules/nostr-feed/components/SubmissionDetail.vue b/src/modules/nostr-feed/components/SubmissionDetail.vue index a4f2819..7fe5822 100644 --- a/src/modules/nostr-feed/components/SubmissionDetail.vue +++ b/src/modules/nostr-feed/components/SubmissionDetail.vue @@ -4,8 +4,8 @@ * Displays complete submission content and threaded comments */ -import { ref, computed } from 'vue' -import { useRoute, useRouter } from 'vue-router' +import { ref, computed, watch } from 'vue' +import { useRouter } from 'vue-router' import { formatDistanceToNow } from 'date-fns' import { ArrowLeft, @@ -17,9 +17,6 @@ import { Image as ImageIcon, FileText, Loader2, - ChevronUp, - ChevronDown, - Reply, Send } from 'lucide-vue-next' import { Badge } from '@/components/ui/badge' @@ -31,7 +28,6 @@ import { tryInjectService, SERVICE_TOKENS } from '@/core/di-container' import type { ProfileService } from '../services/ProfileService' import type { SubmissionService } from '../services/SubmissionService' import type { - SubmissionWithMeta, SubmissionComment as SubmissionCommentType, LinkSubmission, MediaSubmission, @@ -85,9 +81,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 +197,7 @@ async function submitComment() { await submissionService.createComment( props.submissionId, commentText.value.trim(), - null // Top-level comment + undefined // Top-level comment ) cancelReply() } catch (err: any) { @@ -247,19 +241,37 @@ function toggleCollapse(commentId: string) { collapsedComments.value = new Set(collapsedComments.value) } -// Count total replies -function countReplies(comment: SubmissionCommentType): number { - let count = comment.replies?.length || 0 - comment.replies?.forEach(reply => { - count += countReplies(reply) - }) - return count -} - // Go back 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 })