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: resolve app shortcut navigation and add reminder feature gate
kashaf-ansari-dev62ecc5f7fb02
diff --git a/apps/mobile/app/components/dialog/index.tsx b/apps/mobile/app/components/dialog/index.tsxindex 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.tsxindex 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<NodeJS.Timeout>(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.tsxindex 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<string>();const [selectDayError, setSelectDayError] = useState<string>();+ 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}}/>- <Dialog context="local" /><ScrollViewstyle={{marginBottom: DDS.isTab ? 25 : undefined,