mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
chore(react/collections/list): display children recursively
This commit is contained in:
@@ -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[]>();
|
||||
|
||||
@@ -127,8 +127,6 @@ class ListOrGridView extends ViewMode<{}> {
|
||||
return;
|
||||
}
|
||||
|
||||
const $expander = $card.find("> .note-book-header .note-expander");
|
||||
|
||||
if ((this.viewType === "grid")) {
|
||||
$card.append(await this.renderNoteContent(note));
|
||||
}
|
||||
@@ -148,18 +146,6 @@ class ListOrGridView extends ViewMode<{}> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this.viewType === "list") {
|
||||
const imageLinks = note.getRelations("imageLink");
|
||||
|
||||
const childNotes = (await note.getChildNotes()).filter((childNote) => !imageLinks.find((rel) => rel.value === childNote.noteId));
|
||||
|
||||
for (const childNote of childNotes) {
|
||||
$content.append(await this.renderNote(childNote));
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user