Skip to content

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

feat: refactor

ammarahm-ed821dbc00c93b
diff --git a/apps/mobile/src/screens/editor/EditorHeader.js b/apps/mobile/src/screens/editor/EditorHeader.js
index 181e75063..861ecec19 100644
--- a/apps/mobile/src/screens/editor/EditorHeader.js
+++ b/apps/mobile/src/screens/editor/EditorHeader.js
@@ -32,7 +32,6 @@ import { EditorTitle } from './EditorTitle';
import { ProgressCircle } from './ProgressCircle';
import { safeKeyboardDismiss } from './tiny/tiny';
import { endSearch } from './tiny/toolbar/commands';
-import { toolbarRef } from './tiny/toolbar/constants';
import picker from './tiny/toolbar/picker';
import { editorController, editorState } from './tiptap/utils';
@@ -52,46 +51,31 @@ const EditorHeader = ({ editor }) => {
const _onBackPress = async () => {
setTimeout(async () => {
- closing.current = true;
if (deviceMode !== 'mobile' && fullscreen) {
- eSendEvent(eCloseFullscreenEditor);
+ if (fullscreen) {
+ eSendEvent(eCloseFullscreenEditor);
+ }
return;
}
+
if (deviceMode === 'mobile') {
editorState().movedAway = true;
+ tabBarRef.current?.goToPage(0);
}
- eSendEvent('showTooltip');
- toolbarRef.current?.scrollTo({
- x: 0,
- y: 0,
- animated: false
+ eSendEvent('historyEvent', {
+ undo: 0,
+ redo: 0
});
-
- if (deviceMode !== 'mobile') {
- if (fullscreen) {
- eSendEvent(eCloseFullscreenEditor);
- }
- } else {
- if (deviceMode === 'mobile') {
- tabBarRef.current?.goToPage(0);
- }
- eSendEvent('historyEvent', {
- undo: 0,
- redo: 0
- });
- setTimeout(() => {
- useEditorStore.getState().setCurrentlyEditingNote(null);
- }, 1);
- editorState().currentlyEditing = false;
- keyboardListener.current?.remove();
- editor?.reset();
- Navigation.setRoutesToUpdate([
- Navigation.routeNames.NotesPage,
- Navigation.routeNames.Favorites,
- Navigation.routeNames.Notes,
- Navigation.routeNames.Notebook
- ]);
- }
+ setImmediate(() => useEditorStore.getState().setCurrentlyEditingNote(null));
+ editorState().currentlyEditing = false;
+ keyboardListener.current?.remove();
+ editor?.reset();
+ Navigation.setRoutesToUpdate([
+ Navigation.routeNames.NotesPage,
+ Navigation.routeNames.Favorites,
+ Navigation.routeNames.Notes,
+ Navigation.routeNames.Notebook
+ ]);
}, 1);
};