mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
feat(collections): add label to show archived notes
This commit is contained in:
parent
f300b6c8a2
commit
d1e57e85b6
@ -256,20 +256,20 @@ export default class FNote {
|
||||
return this.children;
|
||||
}
|
||||
|
||||
async getSubtreeNoteIds() {
|
||||
async getSubtreeNoteIds(includeArchived = false) {
|
||||
let noteIds: (string | string[])[] = [];
|
||||
for (const child of await this.getChildNotes()) {
|
||||
if (child.isArchived) continue;
|
||||
if (child.isArchived && !includeArchived) continue;
|
||||
|
||||
noteIds.push(child.noteId);
|
||||
noteIds.push(await child.getSubtreeNoteIds());
|
||||
noteIds.push(await child.getSubtreeNoteIds(includeArchived));
|
||||
}
|
||||
return noteIds.flat();
|
||||
}
|
||||
|
||||
async getSubtreeNotes() {
|
||||
const noteIds = await this.getSubtreeNoteIds();
|
||||
return (await this.froca.getNotes(noteIds)).filter(note => !note.isArchived)
|
||||
return (await this.froca.getNotes(noteIds));
|
||||
}
|
||||
|
||||
async getChildNotes() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { allViewTypes, ViewModeProps, ViewTypeOptions } from "./interface";
|
||||
import { useNoteContext, useNoteLabel, useTriliumEvent } from "../react/hooks";
|
||||
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } from "../react/hooks";
|
||||
import FNote from "../../entities/fnote";
|
||||
import "./NoteList.css";
|
||||
import { ListView, GridView } from "./legacy/ListOrGridView";
|
||||
@ -109,6 +109,7 @@ function useNoteViewType(note?: FNote | null): ViewTypeOptions | undefined {
|
||||
|
||||
function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOptions | undefined) {
|
||||
const [ noteIds, setNoteIds ] = useState<string[]>([]);
|
||||
const [ includeArchived ] = useNoteLabelBoolean(note, "includeArchived");
|
||||
|
||||
async function refreshNoteIds() {
|
||||
if (!note) {
|
||||
@ -118,12 +119,12 @@ function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOptions |
|
||||
setNoteIds(note.getChildNoteIds());
|
||||
} else {
|
||||
console.log("Refreshed note IDs");
|
||||
setNoteIds(await note.getSubtreeNoteIds());
|
||||
setNoteIds(await note.getSubtreeNoteIds(includeArchived));
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh on note switch.
|
||||
useEffect(() => { refreshNoteIds() }, [ note ]);
|
||||
useEffect(() => { refreshNoteIds() }, [ note, includeArchived ]);
|
||||
|
||||
// Refresh on alterations to the note subtree.
|
||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user