Skip to content

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

mobile: fix cannot read property 'sortDirection' of undefined

Ammar Ahmed2e226f0f72ee
diff --git a/apps/mobile/app/components/sheets/sort/index.js b/apps/mobile/app/components/sheets/sort/index.js
index 2d7950f41..0e4c9c37a 100644
--- a/apps/mobile/app/components/sheets/sort/index.js
+++ b/apps/mobile/app/components/sheets/sort/index.js
@@ -50,7 +50,7 @@ const Sort = ({ type, screen }) => {
const setOrderBy = async () => {
let _groupOptions = {
...groupOptions,
- sortDirection: groupOptions.sortDirection === "asc" ? "desc" : "asc"
+ sortDirection: groupOptions?.sortDirection === "asc" ? "desc" : "asc"
};
if (type === "topics") {
_groupOptions.groupBy = "none";
@@ -85,7 +85,7 @@ const Sort = ({ type, screen }) => {
<Button
title={
- groupOptions.sortDirection === "asc"
+ groupOptions?.sortDirection === "asc"
? groupOptions.groupBy === "abc" ||
groupOptions.sortBy === "title"
? "A - Z"
@@ -100,7 +100,7 @@ const Sort = ({ type, screen }) => {
: "New - Old"
}
icon={
- groupOptions.sortDirection === "asc"
+ groupOptions?.sortDirection === "asc"
? "sort-ascending"
: "sort-descending"
}
@@ -229,7 +229,7 @@ const Sort = ({ type, screen }) => {
if (item === "abc") {
_groupOptions.sortBy = "title";
- _groupOptions.sortDirection = "asc";
+ _groupOptions.sortDirection = "desc";
}
updateGroupOptions(_groupOptions);