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 loading note in editor at cold launch
Ammar Ahmed5325a3424ff8
diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsxindex 96b8a6fe7..7845896c4 100644--- a/apps/mobile/app/app.tsx+++ b/apps/mobile/app/app.tsx@@ -50,6 +50,7 @@ import {registerAppShortcuts} from "./hooks/use-shortcut-manager";import Shortcuts from "react-native-actions-shortcuts";+import { parseInternalLink } from "@notesnook/core";I18nManager.allowRTL(false);I18nManager.forceRTL(false);I18nManager.swapLeftAndRightInRTL(false);@@ -200,9 +201,12 @@ export const withStartupBoundry = (Linking.getInitialURL(),Shortcuts.getInitialShortcut()]);- console.log(url, shortcut);- if (shortcut?.type === "notesnook.action.newnote") {- launchNewNoteTab();+ const parsedLink = url ? parseInternalLink(url) : undefined;+ if (+ shortcut?.type === "notesnook.action.newnote" ||+ parsedLink?.type === "note"+ ) {+ launchNewNoteTab(parsedLink?.id);}useSettingStore.setState({initialUrl: url,diff --git a/apps/mobile/app/hooks/use-shortcut-manager.ts b/apps/mobile/app/hooks/use-shortcut-manager.tsindex 9b990560c..d42634dbe 100644--- a/apps/mobile/app/hooks/use-shortcut-manager.ts+++ b/apps/mobile/app/hooks/use-shortcut-manager.ts@@ -66,18 +66,18 @@ export function initShortcutListener() {);}-export function launchNewNoteTab() {- let tabId;+export function launchNewNoteTab(noteId?: string) {const currentTab = useTabStore.getState().getTab(useTabStore.getState().currentTab as string);if (useTabStore.getState().tabs.length === 0 || currentTab?.pinned) {- tabId = useTabStore.getState().newTab();+ useTabStore.getState().newTab();} else {- tabId = useTabStore.getState().currentTab;- if (useTabStore.getState().getTab(tabId)?.session?.noteId) {- useTabStore.getState().newTabSession(tabId, {});+ if (currentTab && currentTab?.session?.noteId !== noteId) {+ useTabStore.getState().newTabSession(currentTab?.id, {+ noteId: noteId+ });}}}diff --git a/apps/mobile/app/navigation/navigation-stack.tsx b/apps/mobile/app/navigation/navigation-stack.tsxindex 486b4150c..608b8cd8a 100644--- a/apps/mobile/app/navigation/navigation-stack.tsx+++ b/apps/mobile/app/navigation/navigation-stack.tsx@@ -307,10 +307,14 @@ export const RootNavigation = () => {const introCompleted = useSettingStore((state) => state.settings.introCompleted);-const initialShortcut = React.useRef(useSettingStore.getState().pendingShortcut- ).current;+ );+ const initialUrl = React.useMemo(() => {+ return useSettingStore.getState().initialUrl+ ? parseInternalLink(useSettingStore.getState().initialUrl!)+ : undefined;+ }, []);const reminderFeature = useIsFeatureAvailable("activeReminders");const clearSelection = useSelectionStore((state) => state.clearSelection);@@ -366,7 +370,6 @@ export const RootNavigation = () => {fluidTabsRef.current.goToPage("editor", true);} else {launchNewNoteTab();-rootNavigatorRef.current?.navigate("FluidPanelsView" as any, {initialPage: "editor"});@@ -379,7 +382,7 @@ export const RootNavigation = () => {const initialRouteName = !introCompleted? "Welcome"- : initialShortcut?.type === "notesnook.action.newreminder"+ : initialShortcut.current?.type === "notesnook.action.newreminder"? "AddReminder": "FluidPanelsView";@@ -416,7 +419,8 @@ export const RootNavigation = () => {}}initialParams={{initialPage:- initialShortcut?.type === "notesnook.action.newnote"+ initialShortcut.current?.type === "notesnook.action.newnote" ||+ initialUrl?.type === "note"? "editor": undefined}}