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: add feature manager
Ammar Ahmed39693966c102
diff --git a/apps/mobile/app/hooks/use-app-events.tsx b/apps/mobile/app/hooks/use-app-events.tsxindex 1c819c92d..81a10d99a 100644--- a/apps/mobile/app/hooks/use-app-events.tsx+++ b/apps/mobile/app/hooks/use-app-events.tsx@@ -105,6 +105,7 @@ import { sleep } from "../utils/time";import AddReminder from "../screens/add-reminder";import { isFeatureAvailable } from "@notesnook/common";import PaywallSheet from "../components/sheets/paywall";+import useFeatureManager from "./use-feature-manager";const onCheckSyncStatus = async (type: SyncStatusEvent) => {const { disableSync, disableAutoSync } = SettingsService.get();@@ -443,7 +444,7 @@ export const useAppEvents = () => {state.appLocked,state.syncing]);-+ useFeatureManager();const syncedOnLaunch = useRef(false);const refValues = useRef<Partial<{diff --git a/apps/mobile/app/hooks/use-feature-manager.ts b/apps/mobile/app/hooks/use-feature-manager.tsnew file mode 100644index 000000000..e0375c655--- /dev/null+++ b/apps/mobile/app/hooks/use-feature-manager.ts@@ -0,0 +1,43 @@+import { useIsFeatureAvailable } from "@notesnook/common";+import { strings } from "@notesnook/intl";+import { useEffect } from "react";+import { presentDialog } from "../components/dialog/functions";+import { eSendEvent } from "../services/event-manager";+import Navigation from "../services/navigation";+import SettingsService from "../services/settings";+import { useUserStore } from "../stores/use-user-store";+import { eCloseSimpleDialog } from "../utils/events";++export default function useFeatureManager() {+ const appLockFeature = useIsFeatureAvailable("appLock");+ const user = useUserStore((state) => state.user);++ useEffect(() => {+ if (!user || appLockFeature?.isAllowed) return;+ const unsub = useUserStore.subscribe((state) => {+ if (!state.appLocked && !appLockFeature?.isAllowed) {+ unsub();+ SettingsService.setProperty("appLockEnabled", false);+ setTimeout(() => {+ presentDialog({+ title: "App Lock Disabled",+ paragraph: appLockFeature?.error,+ positiveText: strings.upgrade(),+ negativeText: strings.cancel(),+ positivePress: async () => {+ eSendEvent(eCloseSimpleDialog);+ Navigation.navigate("PayWall", {+ context: "logged-in"+ });+ }+ });+ }, 1000);+ }+ });+ return () => {+ unsub();+ };+ }, [appLockFeature?.isAllowed]);++ return true;+}