Skip to content

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

mobile: get total count on notebook & topic from db

ammarahm-ed0e61731500c8
diff --git a/apps/mobile/app/utils/index.js b/apps/mobile/app/utils/index.js
index 2066a6e49..91ce93781 100755
--- a/apps/mobile/app/utils/index.js
+++ b/apps/mobile/app/utils/index.js
@@ -127,17 +127,13 @@ export function setWidthHeight(size) {
dHeight = size.height;
}
-export function getTotalNotes(notebook) {
- if (!notebook || notebook.type === "header") return 0;
- if (notebook.type === "topic") {
- if (!notebook.notes) return 0;
- return notebook.notes.length;
+export function getTotalNotes(item) {
+ if (!item || item.type === "header") return 0;
+ if (item.type === "topic") {
+ return db.notebooks.notebook(item.notebookId)?.topics.topic(item.id)
+ .totalNotes;
}
- if (!notebook.topics) return 0;
- return notebook.topics.reduce((sum, topic) => {
- let length = topic?.notes ? topic.notes.length : 0;
- return sum + length;
- }, 0);
+ return db.notebooks.notebook(item.id)?.totalNotes;
}
export async function toTXT(note, notitle) {