diff --git a/src/modules/nostr-feed/components/NostrFeed.vue b/src/modules/nostr-feed/components/NostrFeed.vue index 7dc799f..30078b8 100644 --- a/src/modules/nostr-feed/components/NostrFeed.vue +++ b/src/modules/nostr-feed/components/NostrFeed.vue @@ -37,26 +37,30 @@ const { posts: notes, threadedPosts, isLoading, error, refreshFeed } = useFeed({ // Centralized collapse state management const collapsedPosts = ref(new Set()) -// Initialize collapsed state for posts with many replies +// Track which posts should show limited replies (not collapsed, just limited) +const limitedReplyPosts = ref(new Set()) + +// Initialize posts that should show limited replies (>2 children) watch(threadedPosts, (newPosts) => { if (newPosts.length > 0) { - const newCollapsed = new Set(collapsedPosts.value) + const newLimited = new Set() - // Auto-collapse posts with more than 2 direct replies - const addCollapsedPosts = (posts: any[]) => { + // Find posts with more than 2 direct replies - these should show limited replies by default + const findLimitedPosts = (posts: any[]) => { posts.forEach(post => { if ((post.replies?.length || 0) > 2) { - newCollapsed.add(post.id) + // Mark this post as having limited replies shown + newLimited.add(post.id) } // Recursively check nested replies if (post.replies?.length > 0) { - addCollapsedPosts(post.replies) + findLimitedPosts(post.replies) } }) } - addCollapsedPosts(newPosts) - collapsedPosts.value = newCollapsed + findLimitedPosts(newPosts) + limitedReplyPosts.value = newLimited } }, { immediate: true }) @@ -112,6 +116,7 @@ const feedDescription = computed(() => { + // Handle reply to note function onReplyToNote(note: any) { emit('reply-to-note', { @@ -167,6 +172,21 @@ function onToggleCollapse(postId: string) { collapsedPosts.value = newCollapsed } + +// Handle toggle limited replies (show/hide extra replies beyond first 2) +function onToggleLimited(postId: string) { + const newLimited = new Set(limitedReplyPosts.value) + + if (newLimited.has(postId)) { + // Show all replies + newLimited.delete(postId) + } else { + // Limit to first 2 replies + newLimited.add(postId) + } + + limitedReplyPosts.value = newLimited +}