Skip to content

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

fix params not defined issue

ammarahm-edcc77ac0ab2f5
diff --git a/apps/mobile/src/components/Menu/TagsSection.js b/apps/mobile/src/components/Menu/TagsSection.js
index 27de1c49e..1e7b9c24d 100644
--- a/apps/mobile/src/components/Menu/TagsSection.js
+++ b/apps/mobile/src/components/Menu/TagsSection.js
@@ -31,7 +31,7 @@ export const TagsSection = () => {
}, [loading]);
const onPress = item => {
- let params;
+ let params = {};
if (item.type === 'notebook') {
params = {
notebook: item,
@@ -45,7 +45,7 @@ export const TagsSection = () => {
type: item.type
});
} else if (item.type === 'tag') {
- params = params = {
+ params = {
...item,
type: 'tag',
menu: true,
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index dfdb1fbb7..02a213617 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -236,13 +236,13 @@ export const MenuItemsList = [
icon: 'text-box-multiple-outline',
close: true,
func: () => {
- let params = (params = {
+ let params = {
type: 'notes',
menu: true,
get: 'monographs',
title: 'Monographs',
id: 'monographs_navigation'
- });
+ }
eSendEvent(refreshNotesPage, params);
Navigation.navigate('NotesPage', params, {
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 35e17a308..39c320ff2 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -23,11 +23,11 @@ import {
export const Notebook = ({route, navigation}) => {
const [topics, setTopics] = useState(
groupArray(
- route.params.notebook?.topics || [],
+ route?.params.notebook?.topics || [],
db.settings.getGroupOptions('topics')
)
);
- const params = useRef(route.params);
+ const params = useRef(route?.params);
const onLoad = data => {
if (data) params.current = data;
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index ce8e479a2..6ccb706f6 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -19,9 +19,7 @@ import { editing, InteractionManager } from '../../utils';
import { db } from '../../utils/database';
import {
eOnLoadNote,
- eOpenAddTopicDialog,
- eScrollEvent,
- refreshNotesPage
+ eOpenAddTopicDialog, refreshNotesPage
} from '../../utils/Events';
import { openLinkInBrowser } from '../../utils/functions';
import { tabBarRef } from '../../utils/Refs';
@@ -31,7 +29,7 @@ export const Notes = ({route, navigation}) => {
const colors = state.colors;
const [notes, setNotes] = useState([]);
const loading = useNoteStore(state => state.loading);
- let params = route.params ? route.params : null;
+ let params = route?.params ? route.params : null;
const alias = params.type === "tag" ? db.tags.alias(params.id) : params.type === "color" ? db.colors.alias(params.id) : params.title
let ranAfterInteractions = false;
@@ -176,12 +174,12 @@ export const Notes = ({route, navigation}) => {
? '#' + alias
: alias.slice(0, 1).toUpperCase() + alias.slice(1),
color: params.type === 'color' ? params.title.toLowerCase() : null,
- paragraph: route.params.type === 'topic' ? 'Edit topic' : null,
+ paragraph: params.type === 'topic' ? 'Edit topic' : null,
onPress: () => {
- if (route.params.type !== 'topic') return;
+ if (params.type !== 'topic') return;
eSendEvent(eOpenAddTopicDialog, {
- notebookId: route.params.notebookId,
- toEdit: route.params
+ notebookId: params.notebookId,
+ toEdit: params
});
},
icon: 'pencil'
@@ -216,10 +214,10 @@ export const Notes = ({route, navigation}) => {
icon: 'pencil',
title: 'Edit topic',
func: () => {
- if (route.params.type !== 'topic') return;
+ if (params.type !== 'topic') return;
eSendEvent(eOpenAddTopicDialog, {
- notebookId: route.params.notebookId,
- toEdit: route.params
+ notebookId: params.notebookId,
+ toEdit: params
});
}
}
@@ -242,7 +240,7 @@ export const Notes = ({route, navigation}) => {
screen="NotesPage"
action={_onPressBottomButton}
rightButtons={
- route.params.type !== 'topic' ? null : headerRightButtons
+ params.type !== 'topic' ? null : headerRightButtons
}
/>
</ContainerTopSection>