You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
872 B
20 lines
872 B
import { getParentBech32Id, getRootBech32Id } from '@/lib/event' |
|
import client from '@/services/client.service' |
|
import type { Event } from 'nostr-tools' |
|
|
|
/** |
|
* Parent / root events already in the session cache (e.g. from {@link ParentNotePreview} or the feed). |
|
* Passed into {@link navigateToNote} as `relatedEvents` so {@link NotePage} can render the thread strip |
|
* without a refetch — especially when the side panel mounts without `initialEvent`. |
|
*/ |
|
export function getCachedThreadContextEvents(forEvent: Event): Event[] { |
|
const byId = new Map<string, Event>() |
|
const tryAdd = (bech32OrHex?: string) => { |
|
if (!bech32OrHex?.trim()) return |
|
const ev = client.peekSessionCachedEvent(bech32OrHex.trim()) |
|
if (ev) byId.set(ev.id.toLowerCase(), ev) |
|
} |
|
tryAdd(getParentBech32Id(forEvent)) |
|
tryAdd(getRootBech32Id(forEvent)) |
|
return [...byId.values()] |
|
}
|
|
|