data endpoint for entity 90008 (aka. a website)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: find reply root properly

dusk 7440f613 b2915e30

+9 -8
+9 -8
src/lib/notes.ts
··· 32 32 return JSON.parse(readFileSync(getNotePath(id)).toString()) 33 33 } 34 34 export const findReplyRoot = (id: NoteId): {rootNote: Note, rootNoteId: NoteId} => { 35 - let currentNoteId: string | null = id 36 - let currentNote: Note | null = null 37 - while (currentNoteId !== null) { 38 - currentNote = readNote(currentNoteId) 39 - currentNoteId = currentNote.replyTo ?? null 35 + let noteId: string | null = id 36 + let current: {rootNote?: Note, rootNoteId?: NoteId} = {} 37 + while (noteId !== null) { 38 + current.rootNote = readNote(noteId) 39 + current.rootNoteId = noteId 40 + noteId = current.rootNote.replyTo ?? null 40 41 } 41 - if (currentNote === null || currentNoteId === null) { 42 + if (current.rootNote === undefined || current.rootNoteId === undefined) { 42 43 throw "no note with id found" 43 44 } 44 45 return { 45 - rootNote: currentNote, 46 - rootNoteId: currentNoteId, 46 + rootNote: current.rootNote, 47 + rootNoteId: current.rootNoteId, 47 48 } 48 49 } 49 50 export const writeNote = (id: NoteId, note: Note) => {