Skip to content

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

fix keyboard flickering on restoring app state

ammarahm-edff06443ba6f7
diff --git a/apps/mobile/initializer.root.js b/apps/mobile/initializer.root.js
index 431ef42b8..fe8a80f59 100644
--- a/apps/mobile/initializer.root.js
+++ b/apps/mobile/initializer.root.js
@@ -49,7 +49,7 @@ const onChangeTab = async (obj) => {
activateKeepAwake();
eSendEvent('navigate');
eSendEvent(eClearEditor, 'addHandler');
- if (!editing.currentlyEditing || !getNote()) {
+ if (!editing.isRestoringState && (!editing.currentlyEditing || !getNote())) {
eSendEvent(eOnLoadNote, {type: 'new'});
editing.currentlyEditing = true;
}
diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.js
index b38d496d2..d7f65bf82 100644
--- a/apps/mobile/src/components/AppLoader/index.js
+++ b/apps/mobile/src/components/AppLoader/index.js
@@ -9,14 +9,14 @@ import {
eSubscribeEvent,
eUnSubscribeEvent,
} from '../../services/EventManager';
-import { editing } from '../../utils';
+import {editing} from '../../utils';
import {changeContainerScale, ContainerScale} from '../../utils/Animations';
import {db} from '../../utils/DB';
import {eOpenRateDialog, eOpenSideMenu} from '../../utils/Events';
import {MMKV} from '../../utils/mmkv';
import {tabBarRef} from '../../utils/Refs';
import {sleep} from '../../utils/TimeUtils';
-import { setNoteOnly } from '../../views/Editor/Functions';
+import {setNoteOnly} from '../../views/Editor/Functions';
const scaleV = new Animated.Value(0.95);
const opacityV = new Animated.Value(1);
@@ -32,6 +32,19 @@ const AppLoader = ({onLoad}) => {
opacityV.setValue(1);
return;
}
+ let appState = await MMKV.getItem('appState');
+ if (appState) {
+
+ appState = JSON.parse(appState);
+ if (!appState.movedAway && Date.now() < appState.timestamp + 3600000) {
+ editing.isRestoringState = true;
+ //setNoteOnly(appState.note);
+ editing.currentlyEditing = true;
+ tabBarRef.current?.goToPage(1);
+ eSendEvent('loadingNote', appState.note);
+ }
+ }
+
if (value === 'show') {
opacityV.setValue(0);
setLoading(false);
@@ -49,7 +62,7 @@ const AppLoader = ({onLoad}) => {
changeContainerScale(ContainerScale, 1, 600);
await sleep(150);
setLoading(false);
-
+
animation = false;
await db.notes.init();
dispatch({type: Actions.NOTES});
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index 3122759f5..0f100cc23 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -83,7 +83,7 @@ export const InteractionManager = {
runAfterInteractions: (func, time = 400) => setTimeout(func, time),
};
-export const APP_VERSION = 1360;
+export const APP_VERSION = 1370;
export async function setSetting(settings, name, value) {
let s = {...settings};
@@ -128,6 +128,7 @@ export const editing = {
focusType: null,
movedAway: true,
tooltip: false,
+ isRestoringState:false
};
export const selection = {
data: [],
diff --git a/apps/mobile/src/views/Editor/EditorWrapper.js b/apps/mobile/src/views/Editor/EditorWrapper.js
index a04166127..bf18b9843 100644
--- a/apps/mobile/src/views/Editor/EditorWrapper.js
+++ b/apps/mobile/src/views/Editor/EditorWrapper.js
@@ -3,6 +3,7 @@ import {KeyboardAvoidingView, Platform, SafeAreaView, View} from 'react-native';
import {PanGestureHandler, State} from 'react-native-gesture-handler';
import Animated, {Easing} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
+import Editor from '.';
import {GetPremium} from '../../components/ActionSheetComponent/GetPremium';
import Paragraph from '../../components/Typography/Paragraph';
import {useTracked} from '../../provider';
@@ -11,7 +12,6 @@ import {eSendEvent} from '../../services/EventManager';
import {eOnLoadNote} from '../../utils/Events';
import {editorRef} from '../../utils/Refs';
import EditorOverlay from './EditorOverlay';
-import Editor from "./index"
let prevVal = 0;
let finalValue = 80;
let anim2 = new Animated.Value(0);
@@ -87,7 +87,7 @@ const AnimatedKeyboardView = Animated.createAnimatedComponent(
export const EditorWrapper = ({dimensions}) => {
const [state] = useTracked();
- const {colors} = state;
+ const {colors, loading} = state;
const insets = useSafeAreaInsets();
@@ -176,7 +176,7 @@ export const EditorWrapper = ({dimensions}) => {
</Animated.Text>
</View>
- <Editor />
+ {loading ? null : <Editor />}
<EditorOverlay />
</AnimatedKeyboardView>
</PanGestureHandler>
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index f33bead74..e72d95431 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -195,7 +195,7 @@ export const loadNote = async item => {
}
tiny.call(EditorWebView, tiny.notLoading);
} else {
- if (id === item.id) {
+ if (id === item.id && !item.forced) {
return;
}
eSendEvent('loadingNote', item);
@@ -485,10 +485,9 @@ async function restoreEditorState() {
appState.note.id &&
Date.now() < appState.timestamp + 3600000
) {
+ editing.isRestoringState = true;
eSendEvent('loadingNote', appState.note);
- setNoteOnly(appState.note);
editing.currentlyEditing = true;
- editing.movedAway = true;
tabBarRef.current?.goToPage(1);
setTimeout(() => {
eSendEvent(eOnLoadNote, appState.note);
@@ -496,6 +495,7 @@ async function restoreEditorState() {
MMKV.removeItem('appState');
editing.movedAway = false;
eSendEvent('load_overlay', 'hide_editor');
+ editing.isRestoringState = false;
}
}
}