A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: fix back gesture handler broken in editor
Ammar Ahmedd523db84cccf
diff --git a/apps/mobile/app/components/tabs/index.tsx b/apps/mobile/app/components/tabs/index.tsxindex e565d7e2a..58f364075 100644--- a/apps/mobile/app/components/tabs/index.tsx+++ b/apps/mobile/app/components/tabs/index.tsx@@ -121,7 +121,12 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(function FluidTabs(} else {if (prevWidths.current?.sidebar !== widths.sidebar) {translateX.value =- !appState || appState?.movedAway ? widths.sidebar : editorPosition;+ !appState || (appState && appState?.movedAway)+ ? widths.sidebar+ : editorPosition;+ if (translateX.value === editorPosition) {+ onChangeTab?.({ i: 2, from: 1 });+ }}}isLoaded.current = true;diff --git a/apps/mobile/app/navigation/tabs-holder.js b/apps/mobile/app/navigation/tabs-holder.jsindex 87ab0fd47..2d7ab3acf 100644--- a/apps/mobile/app/navigation/tabs-holder.js+++ b/apps/mobile/app/navigation/tabs-holder.js@@ -64,6 +64,7 @@ import { useSettingStore } from "../stores/use-setting-store";import {eClearEditor,eCloseFullscreenEditor,+ eOnEnterEditor,eOnLoadNote,eOpenFullscreenEditor,eUnlockNote@@ -515,11 +516,12 @@ const _TabsHolder = () => {};export const TabHolder = React.memo(_TabsHolder, () => true);-const onChangeTab = async (obj) => {- if (obj.i === 2) {+const onChangeTab = async (event) => {+ if (event.i === 2) {editorState().movedAway = false;editorState().isFocused = true;activateKeepAwake();+if (!useTabStore.getState().getCurrentNoteId()) {eSendEvent(eOnLoadNote, {newNote: true@@ -529,13 +531,11 @@ const onChangeTab = async (obj) => {useTabStore.getState().getTab(useTabStore.getState().currentTab).locked) {eSendEvent(eUnlockNote);- } else {- editorState().currentlyEditing = true;- eSendEvent(eOnLoadNote);}+ eSendEvent(eOnEnterEditor);}} else {- if (obj.from === 2) {+ if (event.from === 2) {deactivateKeepAwake();editorState().movedAway = true;editorState().isFocused = false;diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsxindex 205447916..1266be16b 100644--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx@@ -60,6 +60,7 @@ import {eClearEditor,eCloseFullscreenEditor,eEditorTabFocused,+ eOnEnterEditor,eOnLoadNote,eOpenFullscreenEditor,eOpenLoginDialog,@@ -269,14 +270,13 @@ export const useEditorEvents = (}, [editor, deviceMode, fullscreen]);const onHardwareBackPress = useCallback(() => {- if (editorState().currentlyEditing) {+ if (tabBarRef.current?.page === 2) {onBackPress();return true;}}, [onBackPress]);- const onLoadNote = useCallback(async () => {- console.log("Loading...");+ const onEnterEditor = useCallback(async () => {InteractionManager.runAfterInteractions(() => {if (!DDS.isTab) {handleBack.current = BackHandler.addEventListener(@@ -331,16 +331,16 @@ export const useEditorEvents = (}, [fullscreen, onHardwareBackPress]);useEffect(() => {- eSubscribeEvent(eOnLoadNote + editor.editorId, onLoadNote);+ eSubscribeEvent(eOnEnterEditor, onEnterEditor);eSubscribeEvent(eClearEditor + editor.editorId,onClearEditorSessionRequest);return () => {eUnSubscribeEvent(eClearEditor, onClearEditorSessionRequest);- eUnSubscribeEvent(eOnLoadNote, onLoadNote);+ eUnSubscribeEvent(eOnEnterEditor, onEnterEditor);};- }, [editor.editorId, onClearEditorSessionRequest, onLoadNote]);+ }, [editor.editorId, onClearEditorSessionRequest, onEnterEditor]);const onMessage = useCallback(async (event: WebViewMessageEvent) => {diff --git a/apps/mobile/app/utils/events.js b/apps/mobile/app/utils/events.jsindex 7ce282550..285cc588e 100644--- a/apps/mobile/app/utils/events.js+++ b/apps/mobile/app/utils/events.js@@ -172,3 +172,4 @@ export const eOnChangeFluidTab = "617";export const eUnlockWithBiometrics = "618";export const eUnlockWithPassword = "619";export const eUpdateNoteInEditor = "620";+export const eOnEnterEditor = "621";