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 opening widget note on app launch
Ammar Ahmed42f9bf1593aa
diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsxindex ee5e6e396..9a6586fe0 100644--- a/apps/mobile/app/app.tsx+++ b/apps/mobile/app/app.tsx@@ -39,7 +39,6 @@ import SettingsService from "./services/settings";import { TipManager } from "./services/tip-manager";import { useThemeStore } from "./stores/use-theme-store";import { useUserStore } from "./stores/use-user-store";-import { IntentService } from "./services/intent";I18nManager.allowRTL(false);I18nManager.forceRTL(false);@@ -49,7 +48,6 @@ if (appLockEnabled || appLockMode !== "none") {useUserStore.getState().lockApp(true);}-IntentService.onLaunch();const App = (props: { configureMode: "note-preview" }) => {useAppEvents();//@ts-ignorediff --git a/apps/mobile/app/hooks/use-app-events.tsx b/apps/mobile/app/hooks/use-app-events.tsxindex a956f4ea7..b005e9dd6 100644--- a/apps/mobile/app/hooks/use-app-events.tsx+++ b/apps/mobile/app/hooks/use-app-events.tsx@@ -50,6 +50,7 @@ import { MMKV } from "../common/database/mmkv";import { endProgress, startProgress } from "../components/dialogs/progress";import Migrate from "../components/sheets/migrate";import NewFeature from "../components/sheets/new-feature";+import ReminderSheet from "../components/sheets/reminder";import { Walkthrough } from "../components/walkthroughs";import {resetTabStore,@@ -58,7 +59,8 @@ import {import {clearAppState,editorController,- editorState+ editorState,+ setAppState} from "../screens/editor/tiptap/utils";import { useDragState } from "../screens/settings/editor/state";import BackupService from "../services/backup";@@ -69,7 +71,6 @@ import {eSubscribeEvent,presentSheet} from "../services/event-manager";-import { IntentService } from "../services/intent";import {clearMessage,setEmailVerifyMessage,@@ -98,7 +99,6 @@ import {eLoginSessionExpired,eOnLoadNote,eOpenAnnouncementDialog,- eUnlockNote,eUserLoggedIn,refreshNotesPage} from "../utils/events";@@ -106,7 +106,6 @@ import { getGithubVersion } from "../utils/github-version";import { tabBarRef } from "../utils/global-refs";import { NotesnookModule } from "../utils/notesnook-module";import { sleep } from "../utils/time";-import ReminderSheet from "../components/sheets/reminder";const onCheckSyncStatus = async (type: SyncStatusEvent) => {const { disableSync, disableAutoSync } = SettingsService.get();@@ -162,7 +161,6 @@ const onUserSessionExpired = async () => {const onAppOpenedFromURL = async (event: { url: string }) => {const url = event.url;- console.log("URL", url);try {if (url.startsWith("https://app.notesnook.com/account/verified")) {await onUserEmailVerified();@@ -751,13 +749,15 @@ export const useAppEvents = () => {setTimeout(() => {sub = AppState.addEventListener("change", onAppStateChanged);if (- refValues.current.initialUrl?.startsWith(- "https://app.notesnook.com/account/verified"- )+ refValues.current.initialUrl &&+ !refValues.current.initialUrl?.includes("open_note")) {- onUserEmailVerified();+ onAppOpenedFromURL({+ url: refValues.current.initialUrl!+ });}}, 1000);+refValues.current.removeInternetStateListener = NetInfo.addEventListener(onInternetStateChanged);diff --git a/apps/mobile/app/navigation/navigation-stack.js b/apps/mobile/app/navigation/navigation-stack.jsindex 33415f036..187b82a1c 100644--- a/apps/mobile/app/navigation/navigation-stack.js+++ b/apps/mobile/app/navigation/navigation-stack.js@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/+import { strings } from "@notesnook/intl";import { useThemeColors } from "@notesnook/theme";import { NavigationContainer } from "@react-navigation/native";import { createNativeStackNavigator } from "@react-navigation/native-stack";@@ -44,10 +45,6 @@ import useNavigationStore from "../stores/use-navigation-store";import { useSelectionStore } from "../stores/use-selection-store";import { useSettingStore } from "../stores/use-setting-store";import { rootNavigatorRef } from "../utils/global-refs";-import { strings } from "@notesnook/intl";-import { IntentService } from "../services/intent";-import ReminderSheet from "../components/sheets/reminder";-import { db } from "../common/database";const NativeStack = createNativeStackNavigator();const IntroStack = createNativeStackNavigator();@@ -86,17 +83,6 @@ const _Tabs = () => {React.useEffect(() => {setTimeout(async () => {useNavigationStore.getState().update(homepage);- const intent = IntentService.getLaunchIntent();- if (intent && intent["com.streetwriters.notesnook.OpenReminderId"]) {- const reminder = await db.reminders.reminder(- intent["com.streetwriters.notesnook.OpenReminderId"]- );- if (reminder) {- ReminderSheet.present(reminder);- }- } else if (intent["com.streetwriters.notesnook.NewReminder"]) {- ReminderSheet.present();- }}, 1000);}, [homepage]);diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsxindex 439eb053c..a18752bd8 100644--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx@@ -613,7 +613,7 @@ export const useEditorEvents = (}case EditorEvents.tabFocused: {eSendEvent(eEditorTabFocused, editorMessage.tabId);-+ if (!editor.state.current.initialLoadCalled) break;if (editorMessage.noteId) {if (!useSettingStore.getState().isAppLoading) {const note = await db.notes.note(editorMessage.noteId);diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.tsindex 7c6c4b56f..04750137c 100644--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts@@ -77,6 +77,7 @@ import {isEditorLoaded,post} from "./utils";+import { Linking } from "react-native";const loadNoteMutex = new Mutex();@@ -1055,30 +1056,33 @@ export const useEditor = (state.current.ready = true;}- const appState = getAppState();- if (appState?.noteId) {- const note = await db.notes?.note(appState.noteId);- if (note) {- loadNote({- item: note- });- }- } else {- const noteId = useTabStore.getState().getCurrentNoteId();- if (!noteId) {- loadNote({ newNote: true });- if (tabBarRef.current?.page() === 1) {- state.current.currentlyEditing = false;- }- } else if (state.current?.initialLoadCalled) {- const note = currentNotes.current[noteId];+ if (!state.current?.initialLoadCalled) {+ const url = await Linking.getInitialURL();+ let noteId = url && new URL(url).searchParams.get("id");+ if (noteId) {+ const note = await db.notes?.note(noteId);if (note) {loadNote({item: note});}- }- if (!state.current?.initialLoadCalled) {+ tabBarRef.current?.goToPage(1);+ } else {+ noteId = useTabStore.getState().getCurrentNoteId() || null;+ if (!noteId) {+ loadNote({ newNote: true });+ if (tabBarRef.current?.page() === 1) {+ state.current.currentlyEditing = false;+ }+ } else {+ const note = await db.notes.note(noteId);+ if (note) {+ loadNote({+ item: note+ });+ }+ }+state.current.initialLoadCalled = true;}overlay(false);