From 62ecc5f7fb0228a2a0d545e63af308bdb8c4c358 Mon Sep 17 00:00:00 2001 From: kashaf-ansari-dev Date: Thu, 16 Jul 2026 13:27:58 +0500 Subject: [PATCH] mobile: resolve app shortcut navigation and add reminder feature gate Signed-off-by: kashaf-ansari-dev --- apps/mobile/app/components/dialog/index.tsx | 3 -- .../app/navigation/navigation-stack.tsx | 41 ++++++++++++++++--- .../mobile/app/screens/add-reminder/index.tsx | 20 ++++++++- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/apps/mobile/app/components/dialog/index.tsx b/apps/mobile/app/components/dialog/index.tsx index c4e6a1080..3eaa4d092 100644 --- a/apps/mobile/app/components/dialog/index.tsx +++ b/apps/mobile/app/components/dialog/index.tsx @@ -143,9 +143,6 @@ export const Dialog = ({ context = "global" }: { context?: string }) => { }, [hide, show]); const onNegativePress = async () => { - if (dialogInfo?.onClose) { - await dialogInfo.onClose(); - } hide(); }; diff --git a/apps/mobile/app/navigation/navigation-stack.tsx b/apps/mobile/app/navigation/navigation-stack.tsx index 486bedf14..f1255a6aa 100644 --- a/apps/mobile/app/navigation/navigation-stack.tsx +++ b/apps/mobile/app/navigation/navigation-stack.tsx @@ -29,11 +29,14 @@ import { useSelectionStore } from "../stores/use-selection-store"; import { useSettingStore } from "../stores/use-setting-store"; import { fluidTabsRef, rootNavigatorRef } from "../utils/global-refs"; import Navigation from "../services/navigation"; -import { isFeatureAvailable } from "@notesnook/common"; +import { isFeatureAvailable, useIsFeatureAvailable } from "@notesnook/common"; import { isInternalLink, parseInternalLink } from "@notesnook/core"; import { eSendEvent } from "../services/event-manager"; import { editorState } from "../screens/editor/tiptap/utils"; import { eOnLoadNote } from "../utils/events"; +import { strings } from "@notesnook/intl"; +import PaywallSheet from "../components/sheets/paywall"; +import { presentDialog } from "../components/dialog/functions"; const RootStack = createNativeStackNavigator(); const AppStack = createNativeStackNavigator(); @@ -307,6 +310,7 @@ export const RootNavigation = () => { const pendingShortcutLoaded = useSettingStore( (state) => state.pendingShortcutLoaded ); + const reminderFeature = useIsFeatureAvailable("activeReminders"); const clearSelection = useSelectionStore((state) => state.clearSelection); const resetTimer = React.useRef(undefined); const isNavigationLoaded = React.useRef(true); @@ -338,18 +342,43 @@ export const RootNavigation = () => { if (!pendingShortcut) return; if (pendingShortcut.type === "notesnook.action.newreminder") { + if (reminderFeature === undefined) return; + + if (!reminderFeature.isAllowed) { + presentDialog({ + title: strings.upgrade(), + paragraph: reminderFeature.error, + positiveText: strings.upgrade(), + negativeText: strings.cancel(), + positivePress: async () => { + PaywallSheet.present(reminderFeature); + } + }); + useSettingStore.setState({ pendingShortcut: null }); + return; + } + rootNavigatorRef.current?.navigate("AddReminder" as any); useSettingStore.setState({ pendingShortcut: null }); } else if (pendingShortcut.type === "notesnook.action.newnote") { - rootNavigatorRef.current?.navigate("FluidPanelsView" as any, { - initialPage: !fluidTabsRef.current ? "editor" : undefined - }); + rootNavigatorRef.current?.navigate("FluidPanelsView" as any); - if (fluidTabsRef.current) { + const runNoteLoad = () => { eSendEvent(eOnLoadNote, { newNote: true }); editorState().movedAway = false; - fluidTabsRef.current.goToPage("editor", true); + fluidTabsRef.current?.goToPage("editor", true); useSettingStore.setState({ pendingShortcut: null }); + }; + + if (fluidTabsRef.current) { + runNoteLoad(); + } else { + const unsub = useSettingStore.subscribe((state) => { + if (state.deviceMode && fluidTabsRef.current) { + unsub(); + runNoteLoad(); + } + }); } } }, [pendingShortcut]); diff --git a/apps/mobile/app/screens/add-reminder/index.tsx b/apps/mobile/app/screens/add-reminder/index.tsx index d5aadf7c6..30c29995b 100644 --- a/apps/mobile/app/screens/add-reminder/index.tsx +++ b/apps/mobile/app/screens/add-reminder/index.tsx @@ -64,6 +64,7 @@ import FormInput, { validators } from "../../components/ui/input/form-input"; import AppIcon from "../../components/ui/AppIcon"; +import { presentDialog } from "../../components/dialog/functions"; const ReminderModes = Platform.OS === "ios" @@ -145,6 +146,7 @@ export default function AddReminder(props: NavigationProps<"AddReminder">) { const [repeatFrequency, setRepeatFrequency] = useState(1); const referencedItem = reference ? (reference as Note) : null; const recurringReminderFeature = useIsFeatureAvailable("recurringReminders"); + const activeReminderFeature = useIsFeatureAvailable("activeReminders"); const formRef = useRef( createFormRef({ title: reminder?.title || referencedItem?.title || "", @@ -171,6 +173,23 @@ export default function AddReminder(props: NavigationProps<"AddReminder">) { ); const [dateError, setDateError] = useState(); const [selectDayError, setSelectDayError] = useState(); + useEffect(() => { + if (activeReminderFeature === undefined) return; + if (!activeReminderFeature.isAllowed) { + presentDialog({ + title: strings.upgrade(), + paragraph: activeReminderFeature.error, + positiveText: strings.upgrade(), + negativeText: strings.cancel(), + positivePress: async () => { + PaywallSheet.present(activeReminderFeature); + }, + onClose: () => { + props.navigation.navigate("FluidPanelsView" as any); + } + }); + } + }, [activeReminderFeature]); const showDatePicker = () => { setDatePickerVisibility(true); @@ -291,7 +310,6 @@ export default function AddReminder(props: NavigationProps<"AddReminder">) { onPress: saveReminder }} /> -