Skip to content

Build your personal knowledge base with Trilium Notes

chore(collections/list): use more performant mechanism for searching by note ID

Elian Doran4ecb693be558
diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.ts
index 5b4857accb..230c4783c5 100644
--- a/apps/client/src/entities/fnote.ts
+++ b/apps/client/src/entities/fnote.ts
@@ -6,6 +6,7 @@ import type { Froca } from "../services/froca-interface.js";
import type FAttachment from "./fattachment.js";
import type { default as FAttribute, AttributeType } from "./fattribute.js";
import utils from "../services/utils.js";
+import search from "../services/search.js";
const LABEL = "label";
const RELATION = "relation";
@@ -256,12 +257,18 @@ export default class FNote {
}
async getChildNoteIdsWithArchiveFiltering(includeArchived = false) {
- let noteIds: string[] = [];
- for (const child of await this.getChildNotes()) {
- if (child.isArchived && !includeArchived) continue;
- noteIds.push(child.noteId);
+ if (!includeArchived) {
+ const unorderedIds = new Set(await search.searchForNoteIds(`note.parents.noteId="${this.noteId}" #!archived`));
+ const results: string[] = [];
+ for (const id of this.children) {
+ if (unorderedIds.has(id)) {
+ results.push(id);
+ }
+ }
+ return results;
+ } else {
+ return this.children;
}
- return noteIds;
}
async getSubtreeNoteIds(includeArchived = false) {
diff --git a/apps/client/src/widgets/ribbon/collection-properties-config.ts b/apps/client/src/widgets/ribbon/collection-properties-config.ts
index f59415b793..76a2193c50 100644
--- a/apps/client/src/widgets/ribbon/collection-properties-config.ts
+++ b/apps/client/src/widgets/ribbon/collection-properties-config.ts
@@ -81,7 +81,7 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {
await attributes.removeAttributeById(noteId, expandedAttr.attributeId);
}
- triggerCommand("refreshNoteList", { noteId: noteId });
+ triggerCommand("refreshNoteList", { noteId });
},
},
{