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
fix: remove note from color on delete
thecodrred2624a9187b
diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.jsindex 23d08aa48..031d33c9c 100644--- a/packages/core/__tests__/notes.test.js+++ b/packages/core/__tests__/notes.test.js@@ -261,3 +261,18 @@ test("export note to txt", () =>const txt = await db.notes.note(id).export("txt");expect(txt.includes("Hello")).toBeTruthy();}));++test("deleting a colored note should remove it from that color", () =>+ noteTest().then(async ({ db, id }) => {+ await db.notes.note(id).color("Yellow");+ let color = db.colors.tag("Yellow");++ expect(color).toBeTruthy();+ expect(color.noteIds.indexOf(id)).toBeGreaterThan(-1);++ await db.notes.delete(id);++ color = db.colors.tag("Yellow");+ expect(color).toBeFalsy();+ // TODO expect(color.noteIds.indexOf(id)).toBe(-1);+ }));diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.jsindex 84b56aa46..0ec8b5821 100644--- a/packages/core/collections/notes.js+++ b/packages/core/collections/notes.js@@ -194,8 +194,8 @@ export default class Notes extends Collection {if (!item) continue;const itemData = qclone(item.data);- if (item.notebooks) {- for (let notebook of item.notebooks) {+ if (itemData.notebooks) {+ for (let notebook of itemData.notebooks) {const notebookRef = this._db.notebooks.notebook(notebook.id);if (!notebookRef) continue;@@ -208,11 +208,12 @@ export default class Notes extends Collection {}}- for (let tag of item.tags) {+ for (let tag of itemData.tags) {await this._db.tags.untag(tag, id);}- if (item.data.color) {- await this._db.colors.remove(item.data.color, id);++ if (itemData.color) {+ await this._db.colors.untag(itemData.color, id);}// await this._collection.removeItem(id);if (moveToTrash) await this._db.trash.add(itemData);