chore(react/collections/list): display children recursively

This commit is contained in:
Elian Doran
2025-08-30 16:19:21 +03:00
parent 1c986e2bf6
commit c2a5f437fd
2 changed files with 18 additions and 15 deletions

View File

@@ -55,7 +55,10 @@ function NoteCard({ note, expand }: { note: FNote, expand?: boolean }) {
<Icon className="note-icon" icon={note.getIcon()} />
<NoteLink notePath={notePath} noPreview showNotePath={isSearch} />
<NoteContent note={note} />
{isExpanded && <>
<NoteContent note={note} />
<NoteChildren note={note} />
</>}
</h5>
</div>
)
@@ -80,6 +83,20 @@ function NoteContent({ note, trim }: { note: FNote, trim?: boolean }) {
return <div ref={contentRef} className="note-book-content" />;
}
function NoteChildren({ note }: { note: FNote}) {
const imageLinks = note.getRelations("imageLink");
const [ childNotes, setChildNotes ] = useState<FNote[]>();
useEffect(() => {
note.getChildNotes().then(childNotes => {
const filteredChildNotes = childNotes.filter((childNote) => !imageLinks.find((rel) => rel.value === childNote.noteId));
setChildNotes(filteredChildNotes);
});
}, [ note ]);
return childNotes?.map(childNote => <NoteCard note={childNote} />)
}
function usePagination(note: FNote, noteIds: string[]) {
const [ page, setPage ] = useState(1);
const [ pageNotes, setPageNotes ] = useState<FNote[]>();