Skip to content

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

cleanup

ammarahm-edc493f4681f9e
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 84106d9fd..a24a5bd8b 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -27,7 +27,11 @@ import {
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent, openVault} from '../../services/eventManager';
-import {eOpenLoginDialog, eOpenMoveNoteDialog, refreshNotesPage} from '../../services/events';
+import {
+ eOpenLoginDialog,
+ eOpenMoveNoteDialog,
+ refreshNotesPage,
+} from '../../services/events';
import NavigationService from '../../services/NavigationService';
import {MMKV} from '../../utils/storage';
import {
@@ -214,8 +218,7 @@ export const ActionSheetComponent = ({
close();
setTimeout(() => {
eSendEvent(eOpenMoveNoteDialog);
- },400)
-
+ }, 400);
},
},
{
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 3fe3f0d2e..8865b44f9 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -4,6 +4,7 @@ import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {ph, pv, SIZE, WEIGHT} from '../../common/common';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
+import NavigationService from '../../services/NavigationService';
import {db, ToastEvent} from '../../utils/utils';
import {Button} from '../Button';
import {ActionSheetEvent, moveNoteHideEvent} from '../DialogManager/recievers';
@@ -80,7 +81,12 @@ export const NotebookItem = ({
}}>
{item && item.topics ? (
item.topics.slice(1, 4).map((topic) => (
- <View
+ <TouchableOpacity
+ onPress={() => {
+ NavigationService.navigate('Notes', {
+ ...topic,
+ });
+ }}
key={topic.dateCreated.toString() + topic.title}
style={{
borderRadius: 2.5,
@@ -100,7 +106,7 @@ export const NotebookItem = ({
}}>
{topic.title}
</Text>
- </View>
+ </TouchableOpacity>
))
) : (
<Text
diff --git a/apps/mobile/src/components/SelectionHeader/index.js b/apps/mobile/src/components/SelectionHeader/index.js
index 91ae35fda..bd0c9f5c4 100644
--- a/apps/mobile/src/components/SelectionHeader/index.js
+++ b/apps/mobile/src/components/SelectionHeader/index.js
@@ -1,20 +1,15 @@
-import React, {useState, useEffect} from 'react';
-import {Platform, StatusBar, Text, TouchableOpacity, View} from 'react-native';
-import * as Animatable from 'react-native-animatable';
+import React, {useEffect, useState} from 'react';
+import {Text, TouchableOpacity, View} from 'react-native';
+import Animated, {Easing, useValue} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {SIZE, WEIGHT} from '../../common/common';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
-import {
- eOpenMoveNoteDialog,
- eOpenPremiumDialog,
- eOpenSimpleDialog,
-} from '../../services/events';
+import {eOpenMoveNoteDialog, eOpenSimpleDialog} from '../../services/events';
import {db, ToastEvent} from '../../utils/utils';
import {TEMPLATE_DELETE} from '../DialogManager/templates';
-import Animated, {useValue, Easing} from 'react-native-reanimated';
export const SelectionHeader = () => {
// State
@@ -44,7 +39,7 @@ export const SelectionHeader = () => {
style={{
width: '100%',
position: 'absolute',
- height:50,
+ height: 50,
backgroundColor: colors.bg,
marginTop: insets.top,
justifyContent: 'flex-end',
@@ -126,7 +121,7 @@ export const SelectionHeader = () => {
<Icon color={colors.heading} name={'plus'} size={SIZE.xl} />
</TouchableOpacity>
)}
- {/* {currentScreen === 'trash' || currentScreen === 'notebooks' ? null : (
+ {/* {currentScreen === 'trash' || currentScreen === 'notebooks' ? null : (
<TouchableOpacity
style={{
justifyContent: 'center',
diff --git a/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js b/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
index 742686e97..28c01eb82 100644
--- a/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
+++ b/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
@@ -41,37 +41,31 @@ export const NotebookItemWrapper = ({
onLongPress();
return;
}
- if (item.type === 'topic') {
- NavigationService.navigate('Notes', {
- ...item,
- });
- } else {
- dispatch({
- type: ACTIONS.HEADER_TEXT_STATE,
- state: {
- heading: item.title,
- },
- });
- dispatch({
- type: ACTIONS.HEADER_STATE,
- state: {
- canGoBack: true,
- menu: false,
- },
- });
- dispatch({
- type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
- state: {
- bottomButtonText: 'Add new topic',
- },
- });
+ dispatch({
+ type: ACTIONS.HEADER_TEXT_STATE,
+ state: {
+ heading: item.title,
+ },
+ });
+ dispatch({
+ type: ACTIONS.HEADER_STATE,
+ state: {
+ canGoBack: true,
+ menu: false,
+ },
+ });
+ dispatch({
+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,
+ state: {
+ bottomButtonText: 'Add new topic',
+ },
+ });
- NavigationService.navigate('Notebook', {
- notebook: item,
- title: item.title,
- root: true,
- });
- }
+ NavigationService.navigate('Notebook', {
+ notebook: item,
+ title: item.title,
+ root: true,
+ });
};
return (
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 88d5f06d5..b8dc2b9ee 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -16,6 +16,7 @@ import {
eOnNewTopicAdded,
eScrollEvent,
} from '../../services/events';
+import NavigationService from '../../services/NavigationService';
import {db, ToastEvent, w} from '../../utils/utils';
export const Notebook = ({route, navigation}) => {
@@ -45,10 +46,6 @@ export const Notebook = ({route, navigation}) => {
};
}, []);
- const handleBackPress = () => {
- navigation.goBack();
- };
-
useEffect(() => {
if (isFocused) {
onLoad();
@@ -110,13 +107,6 @@ export const Notebook = ({route, navigation}) => {
}
}, [topics, isFocused]);
- useEffect(() => {
- eSubscribeEvent(eMoveNoteDialogNavigateBack, handleBackPress);
- return () => {
- eUnSubscribeEvent(eMoveNoteDialogNavigateBack, handleBackPress);
- };
- }, []);
-
const _onRefresh = async () => {
setRefreshing(true);
try {
@@ -157,31 +147,36 @@ const RenderItem = ({item, index}) => {
let params = headerState.route.params ? headerState.route.params : {};
return (
- <SelectionWrapper item={item}>
+ <SelectionWrapper
+ onPress={() => {
+ NavigationService.navigate('Notes', {
+ ...item,
+ });
+ }}
+ onLongPress={() => {
+ if (!selectionMode) {
+ dispatch({
+ type: ACTIONS.SELECTION_MODE,
+ enabled: !selectionMode,
+ });
+ }
+ dispatch({
+ type: ACTIONS.SELECTED_ITEMS,
+ item: item,
+ });
+ }}
+ item={item}>
<NotebookItem
hideMore={preventDefaultMargins}
isTopic={true}
customStyle={{
- width: selectionMode ? w - 74 : '100%',
+ width: '100%',
marginHorizontal: 0,
}}
selectionMode={selectionMode}
- onLongPress={() => {
- if (!selectionMode) {
- dispatch({
- type: ACTIONS.SELECTION_MODE,
- enabled: !selectionMode,
- });
- }
- dispatch({
- type: ACTIONS.SELECTED_ITEMS,
- item: item,
- });
- }}
noteToMove={params.note}
notebookID={params.notebook?.id}
isMove={preventDefaultMargins}
- refresh={() => {}}
item={item}
index={index}
colors={colors}