diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsx index b8fd22ba3..e549ae93a 100644 --- a/apps/mobile/app/app.tsx +++ b/apps/mobile/app/app.tsx @@ -57,10 +57,6 @@ const { appLockEnabled, appLockMode } = SettingsService.get(); if (appLockEnabled || appLockMode !== "none") { useUserStore.getState().lockApp(true); } -initShortcutListener(); -Linking.getInitialURL().then((url) => { - useSettingStore.setState({ initialUrl: url }); -}); Shortcuts.getInitialShortcut().then((shortcut) => { useSettingStore.setState({ @@ -68,6 +64,11 @@ Shortcuts.getInitialShortcut().then((shortcut) => { pendingShortcutLoaded: true }); RNBootSplash.hide({ fade: true }); + initShortcutListener(); +}); + +Linking.getInitialURL().then((url) => { + useSettingStore.setState({ initialUrl: url }); }); const App = (props: { configureMode: "note-preview" }) => { diff --git a/apps/mobile/app/components/fluid-panels/index.tsx b/apps/mobile/app/components/fluid-panels/index.tsx index 072be6f7e..45913a669 100644 --- a/apps/mobile/app/components/fluid-panels/index.tsx +++ b/apps/mobile/app/components/fluid-panels/index.tsx @@ -90,7 +90,9 @@ export const FluidPanels = forwardRef(function FluidTabs( initialPage === "editor" ? editorStartPosition : widths ? widths.sidebar : 0 ); const startX = useSharedValue(0); - const currentTab = useSharedValue(initialPage === "editor" ? 2 : 1); + const currentTab = useSharedValue( + initialPage === "editor" && deviceMode !== "tablet" ? 2 : 1 + ); const previousTab = useSharedValue(1); const isDrawerOpen = useSharedValue(false); const gestureStartValue = useSharedValue({ diff --git a/apps/mobile/app/navigation/fluid-panels-view.tsx b/apps/mobile/app/navigation/fluid-panels-view.tsx index 677f6ac31..0a5472555 100644 --- a/apps/mobile/app/navigation/fluid-panels-view.tsx +++ b/apps/mobile/app/navigation/fluid-panels-view.tsx @@ -100,9 +100,10 @@ export const FluidPanelsView = React.memo( if (pendingShortcut?.type === "notesnook.action.newnote") { eSendEvent(eOnLoadNote, { newNote: true }); editorState().movedAway = false; + fluidTabsRef.current?.goToPage("editor", true); useSettingStore.setState({ pendingShortcut: null }); } - }, []); + }, [pendingShortcut]); useDeviceOrientationChange((o) => { if ( diff --git a/apps/mobile/app/navigation/navigation-stack.tsx b/apps/mobile/app/navigation/navigation-stack.tsx index 7dc5cac78..6639c8a10 100644 --- a/apps/mobile/app/navigation/navigation-stack.tsx +++ b/apps/mobile/app/navigation/navigation-stack.tsx @@ -309,7 +309,7 @@ export const RootNavigation = () => { ); const clearSelection = useSelectionStore((state) => state.clearSelection); const resetTimer = React.useRef(undefined); - const isFirstRun = React.useRef(true); + const isNavigationLoaded = React.useRef(true); const onStateChange = React.useCallback( (state: any) => { if (useSelectionStore.getState().selectionMode) { @@ -331,34 +331,17 @@ export const RootNavigation = () => { }, []); React.useEffect(() => { - if (isFirstRun.current) { - isFirstRun.current = false; + if (isNavigationLoaded.current) { + isNavigationLoaded.current = false; return; } if (!pendingShortcut) return; - const routes = rootNavigatorRef.current?.getState()?.routes; - const currentRoute = routes?.[routes.length - 1]?.name; - if (pendingShortcut.type === "notesnook.action.newreminder") { - if (currentRoute !== "AddReminder") { - rootNavigatorRef.current?.navigate("AddReminder" as any); - } + rootNavigatorRef.current?.navigate("AddReminder" as any); useSettingStore.setState({ pendingShortcut: null }); } else if (pendingShortcut.type === "notesnook.action.newnote") { - if (fluidTabsRef.current) { - if (currentRoute !== "FluidPanelsView") { - rootNavigatorRef.current?.navigate("FluidPanelsView" as any); - } - eSendEvent(eOnLoadNote, { newNote: true }); - editorState().movedAway = false; - fluidTabsRef.current.goToPage("editor", true); - useSettingStore.setState({ pendingShortcut: null }); - } else { - if (currentRoute !== "FluidPanelsView") { - rootNavigatorRef.current?.navigate("FluidPanelsView" as any); - } - } + rootNavigatorRef.current?.navigate("FluidPanelsView" as any); } }, [pendingShortcut]);