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
feat: impl totalNotes counts
thecodrr81711d65d2f7
diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.jsindex bae88224e..e0683bf12 100644--- a/packages/core/__tests__/notes.test.js+++ b/packages/core/__tests__/notes.test.js@@ -227,6 +227,8 @@ test("add note to topic", () =>let topic = topics.topic("Home");await topic.add(id);expect(topic.all.length).toBe(1);+ expect(topic.topic.totalNotes).toBe(1);+ expect(db.notebooks.notebook(notebookId).data.totalNotes).toBe(1);let note = db.notes.note(id);expect(note.notebook.id).toBe(notebookId);}));diff --git a/packages/core/collections/topics.js b/packages/core/collections/topics.jsindex f2f1711d9..e3e7a2e0c 100644--- a/packages/core/collections/topics.js+++ b/packages/core/collections/topics.js@@ -29,8 +29,11 @@ export default class Topics {uniqueTopics.findIndex(t => (v.title || v) === (t.title || t)) === i);notebook.data.topics = [];+ notebook.data.totalNotes = 0;for (let topic of uniqueTopics) {- notebook.data.topics.push(makeTopic(topic, this.notebookId));+ let t = makeTopic(topic, this.notebookId);+ notebook.data.topics.push(t);+ notebook.data.totalNotes += t.totalNotes;}await this.notebooks.collection.addItem(notebook.data);}diff --git a/packages/core/models/topic.js b/packages/core/models/topic.jsindex 8498c5235..81d3a4e2f 100644--- a/packages/core/models/topic.js+++ b/packages/core/models/topic.js@@ -48,6 +48,7 @@ export default class Topic {notebook: { id: this.topics.notebookId, topic: this.topic.title }});}+ this.topic.totalNotes++;return await this.save();}@@ -61,6 +62,7 @@ export default class Topic {notebook: {}});}+ this.topic.totalNotes--;return await this.save();}