Skip to content

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

verify that editor is reset before loading new note

ammarahm-edb47d7e0bf2e9
diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.js
index 47bf008bc..1533a27bb 100644
--- a/apps/mobile/src/views/Editor/EditorHeader.js
+++ b/apps/mobile/src/views/Editor/EditorHeader.js
@@ -342,8 +342,6 @@ const EditorHeader = () => {
}}
top={50}
onPress={async () => {
- EditorWebView.current?.reload();
- return;
if (editing.isFocused) {
safeKeyboardDismiss();
editing.isFocused = true;
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index a5a6911ef..2314b92a4 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -274,6 +274,7 @@ export const loadNote = async item => {
if (closingSession) {
eSendEvent('loadingNote', item);
await waitForEvent('session_ended');
+ await sleep(100);
}
closingSession = true;
@@ -319,6 +320,7 @@ export const loadNote = async item => {
requestedReload = true;
updateSessionStatus();
tiny.call(EditorWebView, tiny.notLoading);
+
await checkStatus(false);
} else {
if (id === item.id && !item.forced) {
@@ -676,7 +678,7 @@ export async function clearEditor(
immediate = false
) {
try {
- console.log("closing session: ",closingSession);
+ console.log('closing session: ', closingSession);
closingSession = true;
tiny.call(EditorWebView, tiny.isLoading);
if (clear) {
@@ -694,14 +696,9 @@ export async function clearEditor(
sessionId = null;
let func = async () => {
try {
- console.log('reset editor');
- await sleep(300);
+ console.log('reset editor', closingSession);
reset && EditorWebView.current?.reload();
- // if (DDS.isTab) {
- // await waitForEvent('webviewOk');
- // } else {
- // await sleep(1000);
- // }
+ await waitForEvent('resetcomplete');
editing.focusType = null;
eSendEvent('historyEvent', {
undo: 0,
@@ -907,6 +904,7 @@ export async function saveNote(preventUpdate) {
}
export async function onWebViewLoad(premium, colors) {
+ eSendEvent('resetcomplete');
setTimeout(() => {
if (premium) {
tiny.call(EditorWebView, tiny.setMarkdown, true);