Fix note replies getting reset when opening a modal. Because we're iterating through the stack in app/Modal, the note prop on NoteDetail gets re-supplied when opening a child modal. This nukes replies beause we assign them to a local variable which was getting reactively overwritten. Detaching displayNote from note fixes it. This problem is likely to show up elsewhere.

This commit is contained in:
Jonathan Staab 2023-04-21 11:32:59 -05:00
parent fa1211a2fd
commit 1365e2643f

View File

@ -22,32 +22,31 @@
let sub = null
let loading = true
let feedRelay = null
let displayNote = asDisplayEvent(note)
const setFeedRelay = relay => {
feedRelay = relay
}
$: displayNote = asDisplayEvent(note)
onMount(async () => {
if (!note.pubkey) {
if (!displayNote.pubkey) {
await network.load({
relays: sampleRelays(relays),
filter: {kinds: [1], ids: [note.id]},
filter: {kinds: [1], ids: [displayNote.id]},
onChunk: events => {
note = first(events)
displayNote = first(events)
},
})
}
if (note) {
log("NoteDetail", nip19.noteEncode(note.id), note)
if (displayNote) {
log("NoteDetail", nip19.noteEncode(displayNote.id), displayNote)
sub = network.streamContext({
maxDepth: isMobile ? 3 : 6,
notes: [note],
notes: [displayNote],
onChunk: context => {
note = first(network.applyContext([note], user.applyMutes(context)))
displayNote = first(network.applyContext([displayNote], user.applyMutes(context)))
},
})
}