Skip to content

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

remove editor root

ammarahm-edba90250e7f30
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index e8e8df619..c5d753617 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -1,31 +1,30 @@
import http from 'notes-core/utils/http';
-import React, {useEffect} from 'react';
+import React, { useEffect } from 'react';
import Orientation from 'react-native-orientation';
-import {SafeAreaProvider} from 'react-native-safe-area-context';
+import { SafeAreaProvider } from 'react-native-safe-area-context';
import SplashScreen from 'react-native-splash-screen';
-import {AppRootEvents} from './AppRootEvents';
-import {RootView} from './initializer.root';
+import { AppRootEvents } from './AppRootEvents';
+import { RootView } from './initializer.root';
import AppLoader from './src/components/AppLoader';
-import {useTracked} from './src/provider';
+import { useTracked } from './src/provider';
import {
initialize,
useMessageStore,
useNoteStore,
useSettingStore,
- useUserStore,
+ useUserStore
} from './src/provider/stores';
-import {DDS} from './src/services/DeviceDetection';
+import { DDS } from './src/services/DeviceDetection';
import {
eSendEvent,
eSubscribeEvent,
- eUnSubscribeEvent,
+ eUnSubscribeEvent
} from './src/services/EventManager';
import SettingsService from './src/services/SettingsService';
-import {Tracker} from './src/utils';
-import {db} from './src/utils/DB';
-import {eDispatchAction} from './src/utils/Events';
-import {MMKV} from './src/utils/mmkv';
-import EditorRoot from './src/views/Editor/EditorRoot';
+import { Tracker } from './src/utils';
+import { db } from './src/utils/DB';
+import { eDispatchAction } from './src/utils/Events';
+import { MMKV } from './src/utils/mmkv';
let databaseHasLoaded = false;
@@ -139,7 +138,6 @@ const App = () => {
return (
<SafeAreaProvider>
<RootView />
- <EditorRoot />
<AppRootEvents />
<AppLoader onLoad={loadMainApp} />
</SafeAreaProvider>
diff --git a/apps/mobile/src/views/Editor/EditorRoot.js b/apps/mobile/src/views/Editor/EditorRoot.js
deleted file mode 100644
index a1892d27b..000000000
--- a/apps/mobile/src/views/Editor/EditorRoot.js
+++ /dev/null
@@ -1,154 +0,0 @@
-import React, { useEffect } from 'react';
-import { BackHandler, InteractionManager, Keyboard } from 'react-native';
-import { useSettingStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
-import {
- eSendEvent,
- eSubscribeEvent,
- eUnSubscribeEvent,
- ToastEvent
-} from '../../services/EventManager';
-import { editing } from '../../utils';
-import {
- eClearEditor,
- eCloseFullscreenEditor,
- eOnLoadNote
-} from '../../utils/Events';
-import { tabBarRef } from '../../utils/Refs';
-import {
- checkNote,
- clearEditor,
- clearTimer,
-
- EditorWebView,
-
- isNotedEdited,
- loadNote
-} from './Functions';
-import tiny from './tiny/tiny';
-import { toolbarRef } from './tiny/toolbar/constants';
-
-let handleBack;
-
-const EditorRoot = () => {
- const fullscreen = useSettingStore(state => state.fullscreen);
-
- useEffect(() => {
- eSubscribeEvent(eOnLoadNote, load);
- eSubscribeEvent(eClearEditor, onCallClear);
- return () => {
- eUnSubscribeEvent(eClearEditor, onCallClear);
- eUnSubscribeEvent(eOnLoadNote, load);
- };
- }, []);
-
- useEffect(() => {
- if (fullscreen && DDS.isTab) {
- handleBack = BackHandler.addEventListener('hardwareBackPress', _onBackPress);
- }
-
- return () => {
- clearTimer();
- if (handleBack) {
- handleBack.remove();
- handleBack = null;
- }
- };
- }, [fullscreen]);
-
- const load = async (item) => {
- await loadNote(item);
- InteractionManager.runAfterInteractions(() => {
- Keyboard.addListener('keyboardDidShow', tiny.onKeyboardShow);
- if (!DDS.isTab) {
- handleBack = BackHandler.addEventListener(
- 'hardwareBackPress',
- _onHardwareBackPress,
- );
- }
- });
- };
-
- const onCallClear = async (value) => {
- if (value === 'removeHandler') {
- if (handleBack) {
- handleBack.remove();
- handleBack = null;
- }
- return;
- }
- if (value === 'addHandler') {
- if (handleBack) {
- handleBack.remove();
- handleBack = null;
- }
-
- handleBack = BackHandler.addEventListener(
- 'hardwareBackPress',
- _onHardwareBackPress,
- );
- return;
- }
- if (editing.currentlyEditing) {
- await _onBackPress();
- }
- };
-
- const _onHardwareBackPress = async () => {
- if (editing.currentlyEditing) {
- await _onBackPress();
- return true;
- }
- };
-
-
- const _onBackPress = async () => {
- if (DDS.isTab && fullscreen) {
- eSendEvent(eCloseFullscreenEditor);
- return;
- }
- tiny.call(EditorWebView,tiny.blur);
- setTimeout(async () => {
- eSendEvent('showTooltip');
- toolbarRef.current?.scrollTo({
- x: 0,
- y: 0,
- animated: false,
- });
- editing.isFocused = false;
- editing.currentlyEditing = false;
-
- if (DDS.isTab) {
- if (fullscreen) {
- eSendEvent(eCloseFullscreenEditor);
- }
- } else {
- if (!DDS.isTab) {
- tabBarRef.current?.goToPage(0);
- }
- eSendEvent('historyEvent', {
- undo: 0,
- redo: 0,
- });
-
- if (checkNote() && isNotedEdited()) {
- ToastEvent.show({
- heading: 'Note Saved',
- type: 'success',
- duration:1500
- });
- }
- await clearEditor();
- Keyboard.removeListener('keyboardDidShow', tiny.onKeyboardShow);
- if (handleBack) {
- handleBack.remove();
- handleBack = null;
- }
- }
- }, 50);
- };
-
- return <></>;
-};
-
-export default EditorRoot;