mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
mobile: resolve app shortcut navigation and add reminder feature gate
Signed-off-by: kashaf-ansari-dev <kashafansari3108@gmail.com>
This commit is contained in:
committed by
Ammar Ahmed
parent
3e2847f844
commit
62ecc5f7fb
@@ -143,9 +143,6 @@ export const Dialog = ({ context = "global" }: { context?: string }) => {
|
||||
}, [hide, show]);
|
||||
|
||||
const onNegativePress = async () => {
|
||||
if (dialogInfo?.onClose) {
|
||||
await dialogInfo.onClose();
|
||||
}
|
||||
hide();
|
||||
};
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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" />
|
||||
<ScrollView
|
||||
style={{
|
||||
marginBottom: DDS.isTab ? 25 : undefined,
|
||||
|
||||
Reference in New Issue
Block a user