mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
core: simplify total notes counting in notebooks
This commit is contained in:
committed by
Abdullah Atta
parent
66fe109eb9
commit
b7f035b78e
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user