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

This commit is contained in:
Elian Doran 2025-11-13 10:26:47 +02:00
parent 454310c3e4
commit 4ecb693be5
No known key found for this signature in database
2 changed files with 13 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import type { Froca } from "../services/froca-interface.js";
import type FAttachment from "./fattachment.js"; import type FAttachment from "./fattachment.js";
import type { default as FAttribute, AttributeType } from "./fattribute.js"; import type { default as FAttribute, AttributeType } from "./fattribute.js";
import utils from "../services/utils.js"; import utils from "../services/utils.js";
import search from "../services/search.js";
const LABEL = "label"; const LABEL = "label";
const RELATION = "relation"; const RELATION = "relation";
@ -256,12 +257,18 @@ export default class FNote {
} }
async getChildNoteIdsWithArchiveFiltering(includeArchived = false) { async getChildNoteIdsWithArchiveFiltering(includeArchived = false) {
let noteIds: string[] = []; if (!includeArchived) {
for (const child of await this.getChildNotes()) { const unorderedIds = new Set(await search.searchForNoteIds(`note.parents.noteId="${this.noteId}" #!archived`));
if (child.isArchived && !includeArchived) continue; const results: string[] = [];
noteIds.push(child.noteId); 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) { async getSubtreeNoteIds(includeArchived = false) {

View File

@ -81,7 +81,7 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {
await attributes.removeAttributeById(noteId, expandedAttr.attributeId); await attributes.removeAttributeById(noteId, expandedAttr.attributeId);
} }
triggerCommand("refreshNoteList", { noteId: noteId }); triggerCommand("refreshNoteList", { noteId });
}, },
}, },
{ {