Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: simplify total notes counting in notebooks

Abdullah Attab7f035b78e8e
diff --git a/packages/core/models/notebook.js b/packages/core/models/notebook.js
index 3f94e4a98..7244e6765 100644
--- a/packages/core/models/notebook.js
+++ b/packages/core/models/notebook.js
@@ -22,7 +22,7 @@ import Topics from "../collections/topics";
export default class Notebook {
/**
*
- * @param {Object} notebook
+ * @param {any} notebook
* @param {import ('../api').default} db
*/
constructor(notebook, db) {
@@ -31,9 +31,11 @@ export default class Notebook {
}
get totalNotes() {
- return this._notebook.topics.reduce((sum, topic) => {
- return sum + this._db.notes.topicReferences.count(topic.id);
- }, 0);
+ let count = 0;
+ for (const topic of this._notebook.topics) {
+ count += this._db.notes.topicReferences.count(topic.id);
+ }
+ return count;
}
get title() {