core: simplify total notes counting in notebooks

This commit is contained in:
Abdullah Atta
2023-02-08 15:10:17 +05:00
committed by Abdullah Atta
parent 66fe109eb9
commit b7f035b78e

View File

@@ -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() {