From 3a4a6980c6f9b29d1c68c1d8a05f1e93b4b6f438 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Mon, 20 Oct 2025 08:13:28 +0200 Subject: [PATCH] fix display of highlights in quotes --- src/components/QuoteList/index.tsx | 34 ++++++++++++++++++++------ src/components/ReplyNoteList/index.tsx | 33 ++++++++++++++++++++++--- src/lib/event.ts | 2 +- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/components/QuoteList/index.tsx b/src/components/QuoteList/index.tsx index 4def028..43c91fc 100644 --- a/src/components/QuoteList/index.tsx +++ b/src/components/QuoteList/index.tsx @@ -1,4 +1,4 @@ -import { FAST_READ_RELAY_URLS, ExtendedKind } from '@/constants' +import { FAST_READ_RELAY_URLS } from '@/constants' import { getReplaceableCoordinateFromEvent, isReplaceableEvent } from '@/lib/event' import { normalizeUrl } from '@/lib/url' import { useNostr } from '@/providers/NostrProvider' @@ -37,21 +37,39 @@ export default function QuoteList({ event, className }: { event: Event; classNam ...FAST_READ_RELAY_URLS.map(url => normalizeUrl(url) || url) ])) + const eventId = isReplaceableEvent(event.kind) ? getReplaceableCoordinateFromEvent(event) : event.id + const eventCoordinate = isReplaceableEvent(event.kind) ? getReplaceableCoordinateFromEvent(event) : `${event.kind}:${event.pubkey}:${event.id}` + const { closer, timelineKey } = await client.subscribeTimeline( [ { urls: finalRelayUrls, filter: { - '#q': [ - isReplaceableEvent(event.kind) ? getReplaceableCoordinateFromEvent(event) : event.id + '#q': [eventId], + kinds: [ + kinds.ShortTextNote ], + limit: LIMIT + } + }, + { + urls: finalRelayUrls, + filter: { + '#e': [eventId], + kinds: [ + kinds.Highlights, + kinds.LongFormArticle + ], + limit: LIMIT + } + }, + { + urls: finalRelayUrls, + filter: { + '#a': [eventCoordinate], kinds: [ - kinds.ShortTextNote, kinds.Highlights, - kinds.LongFormArticle, - ExtendedKind.COMMENT, - ExtendedKind.POLL, - ExtendedKind.PUBLIC_MESSAGE + kinds.LongFormArticle ], limit: LIMIT } diff --git a/src/components/ReplyNoteList/index.tsx b/src/components/ReplyNoteList/index.tsx index 7fdea28..d71d827 100644 --- a/src/components/ReplyNoteList/index.tsx +++ b/src/components/ReplyNoteList/index.tsx @@ -89,19 +89,44 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even const currentEventKey = isReplaceableEvent(event.kind) ? getReplaceableCoordinateFromEvent(event) : event.id + // For replaceable events, also check the event ID in case replies are stored there + const eventIdKey = event.id let parentEventKeys = [currentEventKey] + if (isReplaceableEvent(event.kind) && currentEventKey !== eventIdKey) { + parentEventKeys.push(eventIdKey) + } + + console.log('🔍 ReplyNoteList debug:', { + eventId: event.id, + currentEventKey, + repliesMapSize: repliesMap.size, + repliesMapKeys: Array.from(repliesMap.keys()), + repliesForEvent: repliesMap.get(currentEventKey)?.events?.length || 0 + }) + while (parentEventKeys.length > 0) { const events = parentEventKeys.flatMap((id) => repliesMap.get(id)?.events || []) + console.log('🔍 Processing events for keys:', parentEventKeys, 'found:', events.length) + events.forEach((evt) => { if (replyIdSet.has(evt.id)) return - if (mutePubkeySet.has(evt.pubkey)) return - if (hideContentMentioningMutedUsers && isMentioningMutedUsers(evt, mutePubkeySet)) return + if (mutePubkeySet.has(evt.pubkey)) { + console.log('🔍 Filtered out muted user:', evt.pubkey) + return + } + if (hideContentMentioningMutedUsers && isMentioningMutedUsers(evt, mutePubkeySet)) { + console.log('🔍 Filtered out content mentioning muted users') + return + } replyIdSet.add(evt.id) replyEvents.push(evt) + console.log('🔍 Added reply:', evt.id, 'kind:', evt.kind) }) parentEventKeys = events.map((evt) => evt.id) } + + console.log('🔍 Final replies count:', replyEvents.length) // Apply sorting based on the sort parameter @@ -236,7 +261,7 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even if (rootInfo.type === 'E') { filters.push({ '#e': [rootInfo.id], - kinds: [kinds.ShortTextNote], + kinds: [kinds.ShortTextNote, 1111], limit: LIMIT }) if (event.kind !== kinds.ShortTextNote) { @@ -258,7 +283,7 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even filters.push( { '#a': [rootInfo.id], - kinds: [kinds.ShortTextNote], + kinds: [kinds.ShortTextNote, 1111], limit: LIMIT }, { diff --git a/src/lib/event.ts b/src/lib/event.ts index efa7821..b146243 100644 --- a/src/lib/event.ts +++ b/src/lib/event.ts @@ -23,7 +23,7 @@ export function isNsfwEvent(event: Event) { } export function isReplyNoteEvent(event: Event) { - if ([ExtendedKind.COMMENT, ExtendedKind.VOICE_COMMENT].includes(event.kind)) { + if ([ExtendedKind.COMMENT, ExtendedKind.VOICE_COMMENT, 1111].includes(event.kind)) { return true }