diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.js index da46aa434..3e9e1e553 100644 --- a/apps/mobile/share/share.js +++ b/apps/mobile/share/share.js @@ -271,11 +271,6 @@ const ShareView = ({ quicknote = false }) => { setLoadingExtension(false); loadData(); useShareStore.getState().restoreAppendNote(); - sleep(50).then(() => { - sleep(500).then(r => { - Storage.write('shareExtensionOpened', 'opened'); - }); - }); })(); }, []); @@ -291,7 +286,10 @@ const ShareView = ({ quicknote = false }) => { }; const onLoad = editor => { - if (editor) return loadData(); + if (editor) { + Storage.write('shareExtensionOpened', 'opened'); + return loadData(); + } eSendEvent(eOnLoadNote + 'shareEditor', { id: null, content: { diff --git a/apps/mobile/src/navigation/tabsholder.js b/apps/mobile/src/navigation/tabsholder.js index 775b4383a..9aa5e4b77 100644 --- a/apps/mobile/src/navigation/tabsholder.js +++ b/apps/mobile/src/navigation/tabsholder.js @@ -154,9 +154,6 @@ export const TabsHolder = React.memo( }, 2500); } else { setDeviceMode('mobile', size); - setTimeout(() => { - tabBarRef.current?.closeDrawer(); - }, 2500); } } diff --git a/apps/mobile/src/screens/editor/index.tsx b/apps/mobile/src/screens/editor/index.tsx index 8afc93348..54304ee8f 100755 --- a/apps/mobile/src/screens/editor/index.tsx +++ b/apps/mobile/src/screens/editor/index.tsx @@ -5,6 +5,7 @@ import { Platform, ViewStyle } from 'react-native'; import WebView from 'react-native-webview'; import { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes'; import { notesnook } from '../../../e2e/test.ids'; +import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager'; import { useEditorStore } from '../../stores/use-editor-store'; import { getElevation } from '../../utils'; import { db } from '../../utils/database'; @@ -84,8 +85,10 @@ const Editor = React.memo( useEffect(() => { onLoad && onLoad(); + eSubscribeEvent('webview_reset', onError); EV.subscribe(EVENTS.mediaAttachmentDownloaded, onMediaDownloaded); return () => { + eUnSubscribeEvent('webview_reset', onError); EV.unsubscribe(EVENTS.mediaAttachmentDownloaded, onMediaDownloaded); }; }, []); @@ -96,10 +99,11 @@ const Editor = React.memo( } const onError = () => { + console.log('RENDER PROCESS GONE!!!'); editor.setLoading(true); setTimeout(() => editor.setLoading(false), 10); }; - + console.log(editor.loading, 'loading editor'); return editor.loading ? null : ( <> { if (!(await isEditorLoaded(editorRef, sessionIdRef.current))) { + console.log('ON READY CALLED'); overlay(true); setLoading(true); } diff --git a/apps/mobile/src/utils/hooks/useAppEvents.js b/apps/mobile/src/utils/hooks/useAppEvents.js index adda2e578..d6891ad41 100644 --- a/apps/mobile/src/utils/hooks/useAppEvents.js +++ b/apps/mobile/src/utils/hooks/useAppEvents.js @@ -41,6 +41,7 @@ import { } from '../../services/event-manager'; import { useEditorStore } from '../../stores/use-editor-store'; import { useDragState } from '../../screens/settings/editor/state'; +import { sleep } from '../time'; const SodiumEventEmitter = new NativeEventEmitter(NativeModules.Sodium); export const useAppEvents = () => { @@ -418,6 +419,7 @@ export const useAppEvents = () => { } async function checkIntentState() { + console.log(checkIntentState, 'CHECK INTENT STATE'); try { let notesAddedFromIntent = MMKV.getString('notesAddedFromIntent'); let shareExtensionOpened = MMKV.getString('shareExtensionOpened'); @@ -432,14 +434,12 @@ export const useAppEvents = () => { initialize(); eSendEvent(refreshNotesPage); } + console.log('CHECK INTENT STATE', notesAddedFromIntent || shareExtensionOpened); if (notesAddedFromIntent || shareExtensionOpened) { let id = useEditorStore.getState().currentEditingNote; let note = id && db.notes.note(id).data; eSendEvent('loadingNote', note); - editorController.current?.setLoading(true); - setTimeout(() => { - editorController.current?.setLoading(false); - }, 100); + eSendEvent('webview_reset'); MMKV.removeItem('shareExtensionOpened'); } } catch (e) {