Skip to content

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

fix editor loads after delay when app reopens after force closed

ammarahm-ed676439c3c171
diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.js
index de737df91..843cee4de 100644
--- a/apps/mobile/src/components/AppLoader/index.js
+++ b/apps/mobile/src/components/AppLoader/index.js
@@ -12,6 +12,8 @@ import {
import {changeContainerScale, ContainerScale} from '../../utils/Animations';
import {db} from '../../utils/DB';
import {eOpenSideMenu} from '../../utils/Events';
+import {MMKV} from '../../utils/mmkv';
+import {tabBarRef} from '../../utils/Refs';
import {sleep} from '../../utils/TimeUtils';
const scaleV = new Animated.Value(0.95);
@@ -28,8 +30,17 @@ const AppLoader = ({onLoad}) => {
opacityV.setValue(1);
return;
}
+ let appState = await MMKV.getItem('appState');
+ if (appState) {
+ appState = JSON.parse(appState);
+ if (!appState.movedAway) {
+ tabBarRef.current?.goToPage(1);
+ eSendEvent('loadingNote', appState.note);
+ }
+ }
+
if (value === 'show') {
- opacityV.setValue(0)
+ opacityV.setValue(0);
setLoading(false);
return;
}
diff --git a/apps/mobile/src/views/Editor/EditorOverlay.js b/apps/mobile/src/views/Editor/EditorOverlay.js
index f50b0d355..abe0e5909 100644
--- a/apps/mobile/src/views/Editor/EditorOverlay.js
+++ b/apps/mobile/src/views/Editor/EditorOverlay.js
@@ -1,17 +1,17 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import Animated, { Easing, timing, useValue } from 'react-native-reanimated';
-import { Button } from '../../components/Button';
+import React, {useEffect, useState} from 'react';
+import {View} from 'react-native';
+import Animated, {Easing, timing, useValue} from 'react-native-reanimated';
+import {Button} from '../../components/Button';
import Heading from '../../components/Typography/Heading';
import Paragraph from '../../components/Typography/Paragraph';
-import { useTracked } from '../../provider';
+import {useTracked} from '../../provider';
import {
eSendEvent,
eSubscribeEvent,
- eUnSubscribeEvent
+ eUnSubscribeEvent,
} from '../../services/EventManager';
-import { SIZE } from '../../utils/SizeUtils';
-import { sleep, timeConverter } from '../../utils/TimeUtils';
+import {SIZE} from '../../utils/SizeUtils';
+import {sleep, timeConverter} from '../../utils/TimeUtils';
let timer = null;
let timerError = null;
@@ -41,7 +41,7 @@ const EditorOverlay = () => {
duration: 150,
easing: Easing.out(Easing.ease),
}).start(async () => {
- await sleep(150);
+ await sleep(200);
setProgress(1);
opacity.setValue(1);
setLoading(null);
@@ -68,7 +68,7 @@ const EditorOverlay = () => {
justifyContent: 'center',
alignItems: 'center',
opacity: opacity,
- top: loading? 0 : 6000,
+ top: loading ? 0 : 6000,
zIndex: 100,
}}>
<View
@@ -88,14 +88,14 @@ const EditorOverlay = () => {
marginBottom: 15,
borderRadius: 5,
overflow: 'hidden',
- backgroundColor:colors.nav
+ backgroundColor: colors.nav,
}}>
<Animated.View
style={{
height: 10,
borderRadius: 5,
- width:100,
- backgroundColor:colors.accent
+ width: 100,
+ backgroundColor: colors.accent,
}}
/>
</View>
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index 287a10624..36869c429 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -1,20 +1,20 @@
-import { createRef } from 'react';
-import { Platform } from 'react-native';
-import { updateEvent } from '../../components/DialogManager/recievers';
-import { Actions } from '../../provider/Actions';
-import { DDS } from '../../services/DeviceDetection';
-import { eSendEvent, sendNoteEditedEvent } from '../../services/EventManager';
+import {createRef} from 'react';
+import {Platform} from 'react-native';
+import {updateEvent} from '../../components/DialogManager/recievers';
+import {Actions} from '../../provider/Actions';
+import {DDS} from '../../services/DeviceDetection';
+import {eSendEvent, sendNoteEditedEvent} from '../../services/EventManager';
import Navigation from '../../services/Navigation';
-import { editing } from '../../utils';
-import { COLORS_NOTE, COLOR_SCHEME } from '../../utils/Colors';
-import { hexToRGBA } from '../../utils/ColorUtils';
-import { db } from '../../utils/DB';
-import { eOnLoadNote, eShowGetPremium } from '../../utils/Events';
-import { openLinkInBrowser } from '../../utils/functions';
-import { MMKV } from '../../utils/mmkv';
-import { tabBarRef } from '../../utils/Refs';
-import { normalize } from '../../utils/SizeUtils';
-import { sleep, timeConverter } from '../../utils/TimeUtils';
+import {editing} from '../../utils';
+import {COLORS_NOTE, COLOR_SCHEME} from '../../utils/Colors';
+import {hexToRGBA} from '../../utils/ColorUtils';
+import {db} from '../../utils/DB';
+import {eOnLoadNote, eShowGetPremium} from '../../utils/Events';
+import {openLinkInBrowser} from '../../utils/functions';
+import {MMKV} from '../../utils/mmkv';
+import {tabBarRef} from '../../utils/Refs';
+import {normalize} from '../../utils/SizeUtils';
+import {sleep, timeConverter} from '../../utils/TimeUtils';
import tiny from './tiny/tiny';
export let EditorWebView = createRef();
@@ -480,6 +480,7 @@ async function restoreEditorState() {
tabBarRef.current?.goToPage(1);
}
MMKV.removeItem('appState');
+ eSendEvent('load_overlay', 'hide_editor');
}
}
}