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
core: fix adding note to vault should return its id
Abdullah Attaca058650211d
diff --git a/packages/core/__tests__/vault.test.js b/packages/core/__tests__/vault.test.jsindex baa5076a7..dbdd0d2c8 100644--- a/packages/core/__tests__/vault.test.js+++ b/packages/core/__tests__/vault.test.js@@ -143,6 +143,7 @@ test("save an edited locked note", () =>expect(content.data.cipher).toBeTypeOf("string");expect(() => JSON.parse(content.data.cipher)).toThrow();+ expect(note.dateEdited).toBeLessThan((await db.notes.note(id)).dateEdited);}));test("change vault password", () =>diff --git a/packages/core/src/api/vault.ts b/packages/core/src/api/vault.tsindex 1ed099213..8a3f3e2d4 100644--- a/packages/core/src/api/vault.ts+++ b/packages/core/src/api/vault.ts@@ -276,7 +276,11 @@ export default class Vault {}private async lockNote(- item: { content?: NoteContent<false>; sessionId?: string; id: string },+ item: {+ content?: NoteContent<false>;+ sessionId?: string;+ id: string;+ },password: string) {const vault = await this.db.vaults.default();@@ -290,11 +294,13 @@ export default class Vault {// Case: when note is being newly lockedif (!locked && (!data || !type)) {const content = await this.db.content.findByNoteId(id);- if (!content || content.locked)- return await this.db.relations.add(vault, {+ if (!content || content.locked) {+ await this.db.relations.add(vault, {id,type: "note"});+ return id;+ }// NOTE:// At this point, the note already has all the attachments extracted// so we should just encrypt it as normal.@@ -313,13 +319,16 @@ export default class Vault {await this.db.notes.add({id,- headline: ""+ headline: "",+ dateEdited: Date.now()});await this.db.relations.add(vault, {id,type: "note"});++ return id;}private async unlockNote(noteId: string, password?: string, perm = false) {