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: do not allow changing plan if user subscribed to legacy pro sub
Ammar Ahmedd11d66539556
diff --git a/apps/mobile/app/components/sheets/paywall/index.tsx b/apps/mobile/app/components/sheets/paywall/index.tsxindex 2cf9700e4..05e6b5b25 100644--- a/apps/mobile/app/components/sheets/paywall/index.tsx+++ b/apps/mobile/app/components/sheets/paywall/index.tsx@@ -1,4 +1,5 @@import { FeatureId, FeatureResult } from "@notesnook/common";+import { SubscriptionPlan, SubscriptionProvider } from "@notesnook/core";import { strings } from "@notesnook/intl";import { useThemeColors } from "@notesnook/theme";import { useEffect } from "react";@@ -13,6 +14,7 @@ import {ToastManager} from "../../../services/event-manager";import Navigation from "../../../services/navigation";+import PremiumService from "../../../services/premium";import { useUserStore } from "../../../stores/use-user-store";import { eCloseSheet } from "../../../utils/events";import { AppFontSize } from "../../../utils/size";@@ -22,8 +24,6 @@ import AppIcon from "../../ui/AppIcon";import { Button } from "../../ui/button";import Heading from "../../ui/typography/heading";import Paragraph from "../../ui/typography/paragraph";-import { SubscriptionProvider } from "@notesnook/core";-import PremiumService from "../../../services/premium";const isGithubRelease = Config.GITHUB_RELEASE === "true";const INDEX_TO_PLAN = {1: "essential",@@ -187,6 +187,17 @@ export default function PaywallSheet<Tid extends FeatureId>(props: {width: "100%"}}onPress={() => {+ if (+ pricingPlans.user?.subscription.plan ===+ SubscriptionPlan.LEGACY_PRO+ ) {+ ToastManager.show({+ message: strings.cannotChangePlan(),+ context: "local"+ });+ return;+ }+if (isSubscribedOnWeb) {ToastManager.show({message: strings.changePlanOnWeb(),diff --git a/apps/mobile/app/components/sheets/plan-limits/index.tsx b/apps/mobile/app/components/sheets/plan-limits/index.tsxindex 4d6a591ac..c8c99ac0d 100644--- a/apps/mobile/app/components/sheets/plan-limits/index.tsx+++ b/apps/mobile/app/components/sheets/plan-limits/index.tsx@@ -84,6 +84,14 @@ export function PlanLimits() {<Buttontitle={strings.changePlan()}onPress={() => {+ if (user?.subscription?.plan === SubscriptionPlan.LEGACY_PRO) {+ ToastManager.show({+ message: strings.cannotChangePlan(),+ context: "local"+ });+ return;+ }+if (user?.subscription.plan !== SubscriptionPlan.FREE &&user?.subscription.productId.includes("5year")diff --git a/apps/mobile/app/hooks/use-feature-manager.ts b/apps/mobile/app/hooks/use-feature-manager.tsindex 57e236704..b06c3d665 100644--- a/apps/mobile/app/hooks/use-feature-manager.ts+++ b/apps/mobile/app/hooks/use-feature-manager.ts@@ -25,6 +25,7 @@ export default function useFeatureManager() {"fullOfflineMode"]);const user = useUserStore((state) => state.user);+ const plan = useUserStore((state) => state.user?.subscription?.plan);useEffect(() => {if (!user || !features) return;@@ -97,7 +98,7 @@ export default function useFeatureManager() {return () => {unsub?.();};- }, [features]);+ }, [features, plan]);return true;}diff --git a/apps/mobile/app/screens/settings/user-section.jsx b/apps/mobile/app/screens/settings/user-section.jsxindex 896cf28f0..3556bd24f 100644--- a/apps/mobile/app/screens/settings/user-section.jsx+++ b/apps/mobile/app/screens/settings/user-section.jsx@@ -348,6 +348,16 @@ const SettingsUserSection = ({ item }) => {: strings.upgradePlan()}onPress={() => {+ if (+ user?.subscription?.plan === SubscriptionPlan.LEGACY_PRO+ ) {+ ToastManager.show({+ message: strings.cannotChangePlan(),+ context: "local"+ });+ return;+ }+if (user.subscription.plan !== SubscriptionPlan.FREE &&user.subscription.productId.includes("5year")diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.poindex 04ddaa5e2..0240340f2 100644--- a/packages/intl/locale/en.po+++ b/packages/intl/locale/en.po@@ -7371,6 +7371,10 @@ msgstr "Your changes have been saved and will be reflected after the app has refmsgid "Your current 2FA method is {method}"msgstr "Your current 2FA method is {method}"+#: src/strings.ts:2593+msgid "Your current subscription does not allow changing plans"+msgstr "Your current subscription does not allow changing plans"+#: src/strings.ts:1800msgid "Your data recovery key is basically a hashed version of your password (plus some random salt). It can be used to decrypt your data for re-encryption."msgstr "Your data recovery key is basically a hashed version of your password (plus some random salt). It can be used to decrypt your data for re-encryption."diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.poindex bb1add46a..bf04114ad 100644--- a/packages/intl/locale/pseudo-LOCALE.po+++ b/packages/intl/locale/pseudo-LOCALE.po@@ -7317,6 +7317,10 @@ msgstr ""msgid "Your current 2FA method is {method}"msgstr ""+#: src/strings.ts:2593+msgid "Your current subscription does not allow changing plans"+msgstr ""+#: src/strings.ts:1800msgid "Your data recovery key is basically a hashed version of your password (plus some random salt). It can be used to decrypt your data for re-encryption."msgstr ""diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.tsindex 83b77e841..cd6213765 100644--- a/packages/intl/src/strings.ts+++ b/packages/intl/src/strings.ts@@ -2588,5 +2588,7 @@ Use this if changes from other devices are not appearing on this device. This wispecialOffer: () => t`Special Offer`,changePlanOnWeb: () =>t`You can change your subscription plan from the web app`,- announcement: () => t`ANNOUNCEMENT`+ announcement: () => t`ANNOUNCEMENT`,+ cannotChangePlan: () =>+ t`Your current subscription does not allow changing plans`};