Skip to content

Commit 4ecb693

Browse files
committed
chore(collections/list): use more performant mechanism for searching by note ID
1 parent 454310c commit 4ecb693

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

apps/client/src/entities/fnote.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Froca } from "../services/froca-interface.js";
66
import type FAttachment from "./fattachment.js";
77
import type { default as FAttribute, AttributeType } from "./fattribute.js";
88
import utils from "../services/utils.js";
9+
import search from "../services/search.js";
910

1011
const LABEL = "label";
1112
const RELATION = "relation";
@@ -256,12 +257,18 @@ export default class FNote {
256257
}
257258

258259
async getChildNoteIdsWithArchiveFiltering(includeArchived = false) {
259-
let noteIds: string[] = [];
260-
for (const child of await this.getChildNotes()) {
261-
if (child.isArchived && !includeArchived) continue;
262-
noteIds.push(child.noteId);
260+
if (!includeArchived) {
261+
const unorderedIds = new Set(await search.searchForNoteIds(`note.parents.noteId="${this.noteId}" #!archived`));
262+
const results: string[] = [];
263+
for (const id of this.children) {
264+
if (unorderedIds.has(id)) {
265+
results.push(id);
266+
}
267+
}
268+
return results;
269+
} else {
270+
return this.children;
263271
}
264-
return noteIds;
265272
}
266273

267274
async getSubtreeNoteIds(includeArchived = false) {

apps/client/src/widgets/ribbon/collection-properties-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const bookPropertiesConfig: Record<ViewTypeOptions, BookConfig> = {
8181
await attributes.removeAttributeById(noteId, expandedAttr.attributeId);
8282
}
8383

84-
triggerCommand("refreshNoteList", { noteId: noteId });
84+
triggerCommand("refreshNoteList", { noteId });
8585
},
8686
},
8787
{

0 commit comments

Comments
 (0)