Skip to content

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

some cleanup

ammarahm-ed708e2e93d849
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index ee645b0d6..84106d9fd 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -27,7 +27,7 @@ import {
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent, openVault} from '../../services/eventManager';
-import {eOpenLoginDialog, refreshNotesPage} from '../../services/events';
+import {eOpenLoginDialog, eOpenMoveNoteDialog, refreshNotesPage} from '../../services/events';
import NavigationService from '../../services/NavigationService';
import {MMKV} from '../../utils/storage';
import {
@@ -211,8 +211,11 @@ export const ActionSheetComponent = ({
func: () => {
dispatch({type: ACTIONS.MODAL_NAVIGATOR, enabled: true});
dispatch({type: ACTIONS.SELECTED_ITEMS, item: note});
-
- close('movenote');
+ close();
+ setTimeout(() => {
+ eSendEvent(eOpenMoveNoteDialog);
+ },400)
+
},
},
{
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index a63c8549c..a09bff34b 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -87,11 +87,13 @@ export class DialogManager extends Component {
};
_showMoveNote = () => {
- this.moveNoteDialog.open();
+
+ ///this.moveNoteDialog.open();
};
_hideMoveNote = () => {
- this.moveNoteDialog.close();
+ //eSendEvent(eCloseMoveNoteDialog)
+ // this.moveNoteDialog.close();
};
loadNote = i => {
@@ -189,17 +191,17 @@ export class DialogManager extends Component {
};
showAddNotebook = data => {
- /* this.setState(
+ this.setState(
{
item: data.item ? data.item : {},
},
() => {
this.addNotebooksDialog.open();
},
- ); */
+ );
};
hideAddNotebook = () => {
- //this.addNotebooksDialog.close();
+ this.addNotebooksDialog.close();
};
_showSimpleDialog = data => {
@@ -252,7 +254,7 @@ export class DialogManager extends Component {
break;
}
case 'movenote': {
- moveNoteEvent();
+ // this._showMoveNote();
break;
}
case "premium": {
diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js
index ddce91cf6..fb4116fae 100644
--- a/apps/mobile/src/components/MoveNoteDialog/index.js
+++ b/apps/mobile/src/components/MoveNoteDialog/index.js
@@ -1,26 +1,26 @@
-import React, { createRef, useEffect, useState } from 'react';
+import React, {createRef, useEffect, useState} from 'react';
import {
FlatList,
Modal,
Text,
TextInput,
TouchableOpacity,
- View
+ View,
} from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { pv, SIZE, WEIGHT } from '../../common/common';
-import { useTracked } from '../../provider';
-import { ACTIONS } from '../../provider/actions';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/eventManager';
-import { eOpenMoveNoteDialog } from '../../services/events';
-import { db, DDS, getElevation, ToastEvent } from '../../utils/utils';
-import { PressableButton } from '../PressableButton';
-import { Toast } from '../Toast';
+import {pv, SIZE, WEIGHT} from '../../common/common';
+import {useTracked} from '../../provider';
+import {ACTIONS} from '../../provider/actions';
+import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager';
+import {eOpenMoveNoteDialog} from '../../services/events';
+import {db, DDS, getElevation, ToastEvent} from '../../utils/utils';
+import {PressableButton} from '../PressableButton';
+import {Toast} from '../Toast';
const MoveNoteDialog = () => {
const [state, dispatch] = useTracked();
const {notebooks, colors, selectedItemsList} = state;
- const [visible, setVisible] = useState(true);
+ const [visible, setVisible] = useState(false);
const [animated, setAnimated] = useState(false);
const [expanded, setExpanded] = useState('');
const [notebookInputFocused, setNotebookInputFocused] = useState(false);
@@ -40,7 +40,6 @@ const MoveNoteDialog = () => {
};
useEffect(() => {
- console.log(notebooks);
eSubscribeEvent(eOpenMoveNoteDialog, open);
return () => {
eUnSubscribeEvent(eOpenMoveNoteDialog, open);
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index ced2560f4..3fe3f0d2e 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -25,7 +25,7 @@ export const NotebookItem = ({
<View
style={[
{
- height: isTopic ? 80 : 120,
+ height: isTopic ? 80 : 110,
justifyContent: 'space-between',
alignItems: 'center',
flexDirection: 'row',
@@ -39,8 +39,8 @@ export const NotebookItem = ({
]}>
<View
style={{
- width: hideMore ? '80%' : '90%',
- maxWidth: hideMore ? '80%' : '90%',
+ width: '90%',
+ maxWidth: '90%',
minHeight: 50,
justifyContent: 'center',
}}>
@@ -76,6 +76,7 @@ export const NotebookItem = ({
width: '80%',
maxWidth: '80%',
flexWrap: 'wrap',
+ paddingVertical: item.description ? 0 : 5,
}}>
{item && item.topics ? (
item.topics.slice(1, 4).map((topic) => (
@@ -180,8 +181,7 @@ export const NotebookItem = ({
</Text>
</View>
</View>
- {hideMore ||
- (item.title === 'General' && item.type === 'topic') ? null : (
+ {item.title === 'General' && item.type === 'topic' ? null : (
<TouchableOpacity
style={{
justifyContent: 'center',
@@ -205,30 +205,6 @@ export const NotebookItem = ({
<Icon name="dots-horizontal" size={SIZE.lg} color={colors.heading} />
</TouchableOpacity>
)}
-
- {hideMore && isTopic ? (
- <Button
- width="20%"
- title="Move"
- onPress={async () => {
- let noteIds = [];
- selectedItemsList.forEach((item) => noteIds.push(item.id));
-
- await db.notes.move(
- {
- topic: item.title,
- id: item.notebookId,
- },
- ...noteIds,
- );
- dispatch({type: ACTIONS.CLEAR_SELECTION});
-
- moveNoteHideEvent();
-
- ToastEvent.show(`Note moved to ${item.title}`, 'success');
- }}
- />
- ) : null}
</View>
);
};
diff --git a/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js b/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
index 3d051706a..742686e97 100644
--- a/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
+++ b/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js
@@ -49,7 +49,7 @@ export const NotebookItemWrapper = ({
dispatch({
type: ACTIONS.HEADER_TEXT_STATE,
state: {
- heading: preventDefaultMargins ? 'Move to topic' : item.title,
+ heading: item.title,
},
});
dispatch({
@@ -66,21 +66,11 @@ export const NotebookItemWrapper = ({
},
});
- preventDefaultMargins
- ? navigation.navigate('Notebook', {
- notebook: item,
- title: preventDefaultMargins ? 'Move to topic' : item.title,
- isMove: preventDefaultMargins,
- hideMore: preventDefaultMargins,
- root: preventDefaultMargins ? false : true,
- })
- : NavigationService.navigate('Notebook', {
- notebook: item,
- title: preventDefaultMargins ? 'Select a topic' : item.title,
- isMove: preventDefaultMargins,
- hideMore: preventDefaultMargins,
- root: true,
- });
+ NavigationService.navigate('Notebook', {
+ notebook: item,
+ title: item.title,
+ root: true,
+ });
}
};
@@ -95,7 +85,7 @@ export const NotebookItemWrapper = ({
hideMore={preventDefaultMargins}
navigation={headerState.navigation}
route={headerState.route}
- isTopic={item.type === "topic"}
+ isTopic={item.type === 'topic'}
customStyle={style}
noteToMove={params.note}
item={item}
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index a8ea722a0..2524b3383 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -9,21 +9,12 @@ import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {eScrollEvent} from '../../services/events';
import NavigationService from '../../services/NavigationService';
-import { Placeholder } from '../../components/ListPlaceholders';
+import {Placeholder} from '../../components/ListPlaceholders';
export const Folders = ({route, navigation}) => {
const [state, dispatch] = useTracked();
const {notebooks} = state;
let isFocused = useIsFocused();
- const handleBackPress = () => {
- if (route.params.isMove) {
- return true;
- } else {
- NavigationService.goBack();
- return true;
- }
- };
-
useEffect(() => {
if (isFocused) {
dispatch({
@@ -35,7 +26,6 @@ export const Folders = ({route, navigation}) => {
route: route,
color: null,
navigation: navigation,
- ind:!params.root
},
});
dispatch({
@@ -45,7 +35,6 @@ export const Folders = ({route, navigation}) => {
bottomButtonOnPress: () => AddNotebookEvent(),
color: null,
visible: true,
- ind:!params.root
},
});
dispatch({
@@ -56,7 +45,6 @@ export const Folders = ({route, navigation}) => {
type: ACTIONS.HEADER_TEXT_STATE,
state: {
heading: params.title,
- ind:!params.root
},
});
dispatch({type: ACTIONS.PINNED});
@@ -66,7 +54,6 @@ export const Folders = ({route, navigation}) => {
screen: 'notebooks',
});
}
-
}, [isFocused]);
useEffect(() => {
@@ -74,33 +61,16 @@ export const Folders = ({route, navigation}) => {
dispatch({
type: ACTIONS.SEARCH_STATE,
state: {
- placeholder:params.root? 'Search all notebooks' : 'Select a notebook',
+ placeholder:'Search all notebooks',
data: notebooks,
noSearch: false,
type: 'notebooks',
color: null,
- ind:!params.root
},
});
}
}, [notebooks, isFocused]);
- useEffect(() => {
- eSendEvent(eScrollEvent, 0);
- let backhandler;
-
- backhandler = BackHandler.addEventListener(
- 'hardwareBackPress',
- handleBackPress,
- );
-
- return () => {
- if (!backhandler) return;
- backhandler.remove();
- backhandler = null;
- };
- }, []);
-
const params = route.params;
return (
@@ -109,9 +79,6 @@ export const Folders = ({route, navigation}) => {
type="notebooks"
focused={isFocused}
RenderItem={NotebookItemWrapper}
- hideMore={params.hideMore}
- isMove={params.isMove}
- noteToMove={params.note}
placeholder={<Placeholder type="notebooks" />}
pinned={true}
placeholderText="Notebooks you add will appear here"
diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js
index d4fe004aa..970b614a4 100644
--- a/apps/mobile/src/views/Login/index.js
+++ b/apps/mobile/src/views/Login/index.js
@@ -39,6 +39,7 @@ export const Login = ({route, navigation}) => {
const [username, setUsername] = useState(null);
const [invalidUsername, setInvalidUsername] = useState(false);
const [secureEntry, setSecureEntry] = useState(true);
+
const _email = createRef();
const _pass = createRef();
const _passContainer = createRef();
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 2711841ef..88d5f06d5 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -1,12 +1,11 @@
+import {useIsFocused} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
import {AddTopicEvent} from '../../components/DialogManager/recievers';
-import {NotebookPlaceHolder} from '../../components/ListPlaceholders';
import {NotebookItem} from '../../components/NotebookItem';
import SelectionWrapper from '../../components/SelectionWrapper';
import SimpleList from '../../components/SimpleList';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
-import {useIsFocused} from '@react-navigation/native';
import {
eSendEvent,
eSubscribeEvent,
@@ -16,7 +15,6 @@ import {
eMoveNoteDialogNavigateBack,
eOnNewTopicAdded,
eScrollEvent,
- eSetModalNavigator,
} from '../../services/events';
import {db, ToastEvent, w} from '../../utils/utils';
@@ -26,23 +24,18 @@ export const Notebook = ({route, navigation}) => {
const [refreshing, setRefreshing] = useState(false);
let params = route.params;
- let notebook;
let isFocused = useIsFocused();
const onLoad = () => {
let allTopics;
-
allTopics = db.notebooks.notebook(route.params.notebook.id).data.topics;
- notebook = db.notebooks.notebook(route.params.notebook.id);
setTopics(allTopics);
};
useEffect(() => {
eSendEvent(eScrollEvent, 0);
params = route.params;
- let topic = params.notebook.topics;
- notebook = params.notebook;
- setTopics([...topic]);
+ setTopics([...params.notebook.topics]);
}, []);
useEffect(() => {
@@ -65,11 +58,10 @@ export const Notebook = ({route, navigation}) => {
type: 'topics',
menu: false,
canGoBack: true,
- heading:params.title,
+ heading: params.title,
route: route,
color: null,
navigation: navigation,
- ind: !params.root,
},
});
dispatch({
@@ -82,7 +74,6 @@ export const Notebook = ({route, navigation}) => {
},
color: null,
bottomButtonText: 'Add new topic',
- ind: !params.root
},
});
dispatch({
@@ -94,7 +85,6 @@ export const Notebook = ({route, navigation}) => {
type: ACTIONS.HEADER_TEXT_STATE,
state: {
heading: params.title,
- ind: !params.root
},
});
@@ -102,9 +92,6 @@ export const Notebook = ({route, navigation}) => {
type: ACTIONS.CURRENT_SCREEN,
screen: 'notebook',
});
- if (!params.root) {
- eSendEvent(eSetModalNavigator,true);
- }
}
}, [isFocused]);
@@ -118,7 +105,6 @@ export const Notebook = ({route, navigation}) => {
noSearch: false,
type: 'topics',
color: null,
- ind: !params.root
},
});
}
@@ -165,8 +151,10 @@ export default Notebook;
const RenderItem = ({item, index}) => {
const [state, dispatch] = useTracked();
const {colors, selectionMode, preventDefaultMargins} = state;
- let headerState = preventDefaultMargins? state.indHeaderState : state.headerState;
- let params = headerState.route.params? headerState.route.params : {};
+ let headerState = preventDefaultMargins
+ ? state.indHeaderState
+ : state.headerState;
+ let params = headerState.route.params ? headerState.route.params : {};
return (
<SelectionWrapper item={item}>