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 tags api from notes.js
Waqar Ahmedf8b5e6039e4d
diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.jsindex 5fd2e50c8..3916da885 100644--- a/packages/core/__tests__/notes.test.js+++ b/packages/core/__tests__/notes.test.js@@ -108,7 +108,7 @@ test("add tag to note", () =>let note = db.notes.note(id);await note.tag("hello");expect(note.tags[0]).toBe("hello");- expect(db.notes.tags[0].title).toBe("hello");+ expect(db.tags.all[0].title).toBe("hello");}));test("remove tag from note", () =>@@ -116,10 +116,10 @@ test("remove tag from note", () =>let note = db.notes.note(id);await note.tag("hello");expect(note.tags[0]).toBe("hello");- expect(db.notes.tags[0].title).toBe("hello");+ expect(db.tags.all[0].title).toBe("hello");await note.untag("hello");expect(note.tags.length).toBe(0);- expect(db.notes.tags.length).toBe(0);+ expect(db.tags.all.length).toBe(0);}));test("color a note", () =>@@ -127,7 +127,7 @@ test("color a note", () =>let note = db.notes.note(id);await note.color("red");expect(note.colors[0]).toBe("red");- expect(db.notes.colors[0].title).toBe("red");+ expect(db.colors.all[0].title).toBe("red");}));test("uncolor a note", () =>@@ -135,10 +135,10 @@ test("uncolor a note", () =>let note = db.notes.note(id);await note.color("red");expect(note.colors.length).toBe(1);- expect(db.notes.colors.length).toBe(1);+ expect(db.colors.all.length).toBe(1);await note.uncolor("red");expect(note.colors.length).toBe(0);- expect(db.notes.colors.length).toBe(0);+ expect(db.colors.all.length).toBe(0);}));test("note with text longer than 150 characters should have ... in the headline", () =>@@ -157,7 +157,7 @@ test("get tags", () =>...TEST_NOTE,tags: ["new", "tag", "goes", "here"]}).then(async ({ db }) => {- expect(db.notes.tags.length).toBeGreaterThan(0);+ expect(db.tags.all.length).toBeGreaterThan(0);}));test("get notes in tag", () =>diff --git a/packages/core/api/index.js b/packages/core/api/index.jsindex a17253420..74fab33d3 100644--- a/packages/core/api/index.js+++ b/packages/core/api/index.js@@ -16,11 +16,11 @@ class Database {this.user = new User(this.context);this.tags = new Tags(this.context, "tags");this.colors = new Tags(this.context, "colors");- await this.notes.init(this.notebooks, this.trash);- await this.notebooks.init(this.notes, this.trash);- await this.trash.init(this.notes, this.notebooks);await this.tags.init();await this.colors.init();+ await this.notes.init(this.notebooks, this.trash, this.tags, this.colors);+ await this.notebooks.init(this.notes, this.trash);+ await this.trash.init(this.notes, this.notebooks);this.syncer = new Sync(this);}diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.jsindex 9d972476c..c3325f369 100644--- a/packages/core/collections/notes.js+++ b/packages/core/collections/notes.js@@ -21,8 +21,6 @@ export default class Notes {constructor(context) {this.collection = new CachedCollection(context, "notes");this.deltaStorage = new Storage(context);- this.tagsCollection = new Tags(context, "tags");- this.colorsCollection = new Tags(context, "colors");}/**@@ -30,12 +28,14 @@ export default class Notes {* @param {Notebooks} notebooks* @param {Trash} trash*/- async init(notebooks, trash) {+ async init(notebooks, trash, tags, colors) {await this.collection.init();this.notebooks = notebooks;this.trash = trash;- await this.tagsCollection.init();- await this.colorsCollection.init();+// await this.tagsCollection.init();+// await this.colorsCollection.init();+ this.tagsCollection = tags;+ this.colorsCollection = colors;}async add(noteArg) {@@ -194,14 +194,6 @@ export default class Notes {}}- get tags() {- return this.tagsCollection.all();- }-- get colors() {- return this.colorsCollection.all();- }-async move(to, ...noteIds) {if (!to) throw new Error("The destination notebook cannot be undefined.");if (!to.id || !to.topic)diff --git a/packages/core/collections/tags.js b/packages/core/collections/tags.jsindex 2f436b59d..79b8121f6 100644--- a/packages/core/collections/tags.js+++ b/packages/core/collections/tags.js@@ -20,7 +20,7 @@ export default class Tags {await this.collection.addItem(tag);}- all() {+ get all() {return this.collection.getAllItems();}