Skip to content

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

call check status with delay

ammarahm-ed606b5548c9e9
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index 1bd5e26c2..53bc0b8cf 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -1,8 +1,8 @@
-import { createRef } from 'react';
-import { Platform } from 'react-native';
-import { presentDialog } from '../../components/Dialog/functions';
-import { useEditorStore, useMenuStore } from '../../provider/stores';
-import { DDS } from '../../services/DeviceDetection';
+import {createRef} from 'react';
+import {Platform} from 'react-native';
+import {presentDialog} from '../../components/Dialog/functions';
+import {useEditorStore, useMenuStore} from '../../provider/stores';
+import {DDS} from '../../services/DeviceDetection';
import {
eSendEvent,
eSubscribeEvent,
@@ -10,23 +10,23 @@ import {
} from '../../services/EventManager';
import Navigation from '../../services/Navigation';
import PremiumService from '../../services/PremiumService';
-import { editing } from '../../utils';
-import { COLORS_NOTE, COLOR_SCHEME } from '../../utils/Colors';
-import { hexToRGBA } from '../../utils/ColorUtils';
-import { db } from '../../utils/database';
+import {editing} from '../../utils';
+import {COLORS_NOTE, COLOR_SCHEME} from '../../utils/Colors';
+import {hexToRGBA} from '../../utils/ColorUtils';
+import {db} from '../../utils/database';
import {
eOnLoadNote,
eShowGetPremium,
eShowMergeDialog
} from '../../utils/Events';
import filesystem from '../../utils/filesystem';
-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 {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';
-import { IMAGE_TOOLTIP_CONFIG } from './tiny/toolbar/config';
+import {IMAGE_TOOLTIP_CONFIG} from './tiny/toolbar/config';
export let EditorWebView = createRef();
export const editorTitleInput = createRef();
@@ -285,27 +285,32 @@ export const loadNote = async item => {
checkStatus();
} else {
if (id === item.id && !item.forced) {
+ console.log('return from here duhh.');
return;
}
eSendEvent('loadingNote', item);
if (getNote()) {
+ console.log('clearing');
await clearEditor(true, false, true);
}
+ console.log('done clearing');
closingSession = false;
disableSaving = false;
noteEdited = false;
await setNote(item);
webviewInit = false;
editing.isFocused = false;
+ console.log('opening note');
setTimeout(async () => {
if (await checkStatus(true)) {
+ console.log('status checked');
requestedReload = true;
EditorWebView.current?.reload();
} else {
eSendEvent('webviewreset');
}
+ useEditorStore.getState().setCurrentlyEditingNote(item.id);
}, 1);
- useEditorStore.getState().setCurrentlyEditingNote(item.id);
}
};
@@ -323,7 +328,12 @@ const checkStatus = async noreset => {
eUnSubscribeEvent('webviewOk', onWebviewOk);
};
eSubscribeEvent('webviewOk', onWebviewOk);
- EditorWebView.current?.injectJavaScript(CHECK_STATUS);
+ setTimeout(
+ () => {
+ EditorWebView.current?.injectJavaScript(CHECK_STATUS);
+ },
+ Platform.OS === 'ios' ? 300 : 1
+ );
webviewTimer = setTimeout(() => {
if (!webviewOK && !noreset) {