Skip to content

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

fix: add null checks

ammarahm-ed1a3be6b8cdfb
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index c093e4c2a..d4c4ff178 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -111,12 +111,15 @@ export function setWidthHeight(size) {
}
export function getTotalNotes(notebook) {
+ if (!notebook || notebook.type === 'header') return 0;
if (notebook.type === 'topic') {
+ if (!notebook.notes) return 0;
return notebook.notes.length;
}
if (!notebook.topics) return 0;
return notebook.topics.reduce((sum, topic) => {
- return sum + topic.notes.length;
+ let length = topic?.notes ? topic.notes.length : 0;
+ return sum + length;
}, 0);
}