mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 18:39:01 +01:00
chore(collections/list): use more performant mechanism for searching by note ID
This commit is contained in:
parent
454310c3e4
commit
4ecb693be5
@ -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) {
|
||||||
|
|||||||
@ -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 });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user