A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
common: get note's locked status from its content
Abdullah Atta613c1ca30f5c
diff --git a/packages/common/src/utils/resolve-items.ts b/packages/common/src/utils/resolve-items.tsindex b293f2187..3ef124bbd 100644--- a/packages/common/src/utils/resolve-items.ts+++ b/packages/common/src/utils/resolve-items.ts@@ -66,12 +66,18 @@ export type NoteResolvedData = {async function resolveNotes(ids: string[]) {const relations = [...(await db.relations- .to({ type: "note", ids }, ["notebook", "tag", "color", "vault"])+ .to({ type: "note", ids }, ["notebook", "tag", "color"]).get()),...(await db.relations.from({ type: "note", ids }, ["reminder", "attachment"]).get())];+ const lockedReference = await db+ .sql()+ .selectFrom("content")+ .where("noteId", "in", ids)+ .select(["noteId", "locked"])+ .execute();const relationIds: {notebooks: Set<string>;@@ -91,11 +97,11 @@ async function resolveNotes(ids: string[]) {string,{notebooks: string[];- color: string;+ color?: string;tags: string[];reminders: string[];attachments: string[];- locked: boolean;+ locked?: boolean;}> = {};@@ -126,12 +132,21 @@ async function resolveNotes(ids: string[]) {} else if (relation.fromType === "color" && !data.color) {data.color = relation.fromId;relationIds.colors.add(relation.fromId);- } else if (relation.fromType === "vault") {- data.locked = true;}grouped[noteId] = data;}+ for (const ref of lockedReference) {+ if (!ref.noteId) continue;+ grouped[ref.noteId] = grouped[ref.noteId] || {+ attachments: [],+ notebooks: [],+ reminders: [],+ tags: []+ };+ grouped[ref.noteId].locked = !!ref.locked;+ }+const resolved = {notebooks: await db.notebooks.all.records(Array.from(relationIds.notebooks)