verify that editor is reset before loading new note

This commit is contained in:
ammarahm-ed
2021-12-31 19:00:42 +05:00
parent dbca831544
commit b47d7e0bf2
2 changed files with 6 additions and 10 deletions

View File

@@ -342,8 +342,6 @@ const EditorHeader = () => {
}}
top={50}
onPress={async () => {
EditorWebView.current?.reload();
return;
if (editing.isFocused) {
safeKeyboardDismiss();
editing.isFocused = true;

View File

@@ -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);