Browse Source

fix display of highlights in quotes

imwald
Silberengel 5 months ago
parent
commit
3a4a6980c6
  1. 34
      src/components/QuoteList/index.tsx
  2. 33
      src/components/ReplyNoteList/index.tsx
  3. 2
      src/lib/event.ts

34
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 { getReplaceableCoordinateFromEvent, isReplaceableEvent } from '@/lib/event'
import { normalizeUrl } from '@/lib/url' import { normalizeUrl } from '@/lib/url'
import { useNostr } from '@/providers/NostrProvider' 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) ...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( const { closer, timelineKey } = await client.subscribeTimeline(
[ [
{ {
urls: finalRelayUrls, urls: finalRelayUrls,
filter: { filter: {
'#q': [ '#q': [eventId],
isReplaceableEvent(event.kind) ? getReplaceableCoordinateFromEvent(event) : event.id kinds: [
kinds.ShortTextNote
], ],
limit: LIMIT
}
},
{
urls: finalRelayUrls,
filter: {
'#e': [eventId],
kinds: [
kinds.Highlights,
kinds.LongFormArticle
],
limit: LIMIT
}
},
{
urls: finalRelayUrls,
filter: {
'#a': [eventCoordinate],
kinds: [ kinds: [
kinds.ShortTextNote,
kinds.Highlights, kinds.Highlights,
kinds.LongFormArticle, kinds.LongFormArticle
ExtendedKind.COMMENT,
ExtendedKind.POLL,
ExtendedKind.PUBLIC_MESSAGE
], ],
limit: LIMIT limit: LIMIT
} }

33
src/components/ReplyNoteList/index.tsx

@ -89,19 +89,44 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even
const currentEventKey = isReplaceableEvent(event.kind) const currentEventKey = isReplaceableEvent(event.kind)
? getReplaceableCoordinateFromEvent(event) ? getReplaceableCoordinateFromEvent(event)
: event.id : event.id
// For replaceable events, also check the event ID in case replies are stored there
const eventIdKey = event.id
let parentEventKeys = [currentEventKey] 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) { while (parentEventKeys.length > 0) {
const events = parentEventKeys.flatMap((id) => repliesMap.get(id)?.events || []) const events = parentEventKeys.flatMap((id) => repliesMap.get(id)?.events || [])
console.log('🔍 Processing events for keys:', parentEventKeys, 'found:', events.length)
events.forEach((evt) => { events.forEach((evt) => {
if (replyIdSet.has(evt.id)) return if (replyIdSet.has(evt.id)) return
if (mutePubkeySet.has(evt.pubkey)) return if (mutePubkeySet.has(evt.pubkey)) {
if (hideContentMentioningMutedUsers && isMentioningMutedUsers(evt, mutePubkeySet)) return 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) replyIdSet.add(evt.id)
replyEvents.push(evt) replyEvents.push(evt)
console.log('🔍 Added reply:', evt.id, 'kind:', evt.kind)
}) })
parentEventKeys = events.map((evt) => evt.id) parentEventKeys = events.map((evt) => evt.id)
} }
console.log('🔍 Final replies count:', replyEvents.length)
// Apply sorting based on the sort parameter // Apply sorting based on the sort parameter
@ -236,7 +261,7 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even
if (rootInfo.type === 'E') { if (rootInfo.type === 'E') {
filters.push({ filters.push({
'#e': [rootInfo.id], '#e': [rootInfo.id],
kinds: [kinds.ShortTextNote], kinds: [kinds.ShortTextNote, 1111],
limit: LIMIT limit: LIMIT
}) })
if (event.kind !== kinds.ShortTextNote) { if (event.kind !== kinds.ShortTextNote) {
@ -258,7 +283,7 @@ function ReplyNoteList({ index, event, sort = 'oldest' }: { index?: number; even
filters.push( filters.push(
{ {
'#a': [rootInfo.id], '#a': [rootInfo.id],
kinds: [kinds.ShortTextNote], kinds: [kinds.ShortTextNote, 1111],
limit: LIMIT limit: LIMIT
}, },
{ {

2
src/lib/event.ts

@ -23,7 +23,7 @@ export function isNsfwEvent(event: Event) {
} }
export function isReplyNoteEvent(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 return true
} }

Loading…
Cancel
Save