From dae8b5c542499d06629f1b3ea98f75780e368e6e Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Mon, 6 Oct 2025 10:58:39 +0500 Subject: [PATCH 1/2] mobile: hide pricing flows on self hosted clients --- apps/mobile/app/components/auth/login.js | 14 ++---- apps/mobile/app/components/auth/signup.js | 14 +++--- apps/mobile/app/components/paywall/index.tsx | 17 ++----- .../app/components/sheets/paywall/index.tsx | 47 ++++++++++--------- .../components/sheets/plan-limits/index.tsx | 6 ++- .../components/side-menu/side-menu-home.tsx | 11 +++-- apps/mobile/app/hooks/use-feature-manager.ts | 1 + apps/mobile/app/hooks/use-pricing-plans.ts | 20 +++++--- .../app/screens/settings/user-section.jsx | 7 ++- 9 files changed, 74 insertions(+), 63 deletions(-) diff --git a/apps/mobile/app/components/auth/login.js b/apps/mobile/app/components/auth/login.js index b3367cf30..86816d098 100644 --- a/apps/mobile/app/components/auth/login.js +++ b/apps/mobile/app/components/auth/login.js @@ -19,14 +19,11 @@ along with this program. If not, see . import { strings } from "@notesnook/intl"; import { useThemeColors } from "@notesnook/theme"; +import { useRoute } from "@react-navigation/native"; import React, { useEffect, useState } from "react"; -import { - ScrollView, - TouchableOpacity, - View, - useWindowDimensions -} from "react-native"; +import { TouchableOpacity, View, useWindowDimensions } from "react-native"; import { SheetManager } from "react-native-actions-sheet"; +import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; import { DDS } from "../../services/device-detection"; import { eSendEvent } from "../../services/event-manager"; import Navigation from "../../services/navigation"; @@ -47,8 +44,7 @@ import { hideAuth } from "./common"; import { ForgotPassword } from "./forgot-password"; import { AuthHeader } from "./header"; import { useLogin } from "./use-login"; -import { useRoute } from "@react-navigation/native"; -import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; +import SettingsService from "../../services/settings"; const LoginSteps = { emailAuth: 1, @@ -81,7 +77,7 @@ export const Login = ({ changeMode }) => { } }, 5000); - if (!PremiumService.get()) { + if (!PremiumService.get() && !SettingsService.getProperty("serverUrls")) { Navigation.navigate("PayWall", { context: "signup", state: route.params.state, diff --git a/apps/mobile/app/components/auth/signup.js b/apps/mobile/app/components/auth/signup.js index efbe730f3..a862c375b 100644 --- a/apps/mobile/app/components/auth/signup.js +++ b/apps/mobile/app/components/auth/signup.js @@ -19,6 +19,7 @@ along with this program. If not, see . import { strings } from "@notesnook/intl"; import { useThemeColors } from "@notesnook/theme"; +import { useRoute } from "@react-navigation/native"; import React, { useRef, useState } from "react"; import { TouchableOpacity, View, useWindowDimensions } from "react-native"; import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; @@ -38,7 +39,6 @@ import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { AuthHeader } from "./header"; import { SignupContext } from "./signup-context"; -import { useRoute } from "@react-navigation/native"; const SignupSteps = { signup: 0, @@ -91,11 +91,13 @@ export const Signup = ({ changeMode, welcome }) => { setLastSynced(await db.lastSynced()); clearMessage(); setEmailVerifyMessage(); - Navigation.navigate("PayWall", { - canGoBack: false, - state: route.params.state, - context: "signup" - }); + if (!SettingsService.getProperty("serverUrls")) { + Navigation.navigate("PayWall", { + canGoBack: false, + state: route.params.state, + context: "signup" + }); + } return true; } catch (e) { setCurrentStep(SignupSteps.signup); diff --git a/apps/mobile/app/components/paywall/index.tsx b/apps/mobile/app/components/paywall/index.tsx index 1b4dab2c8..7ae559af7 100644 --- a/apps/mobile/app/components/paywall/index.tsx +++ b/apps/mobile/app/components/paywall/index.tsx @@ -60,6 +60,7 @@ import usePricingPlans, { PricingPlan } from "../../hooks/use-pricing-plans"; import Navigation, { NavigationProps } from "../../services/navigation"; +import PremiumService from "../../services/premium"; import { getElevationStyle } from "../../utils/elevation"; import { openLinkInBrowser } from "../../utils/functions"; import { AppFontSize, defaultBorderRadius } from "../../utils/size"; @@ -74,7 +75,6 @@ import { IconButton } from "../ui/icon-button"; import { SvgView } from "../ui/svg"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; -import PremiumService from "../../services/premium"; const Steps = { select: 1, @@ -114,15 +114,8 @@ const PayWall = (props: NavigationProps<"PayWall">) => { routeParams.state?.planId, routeParams.state?.productId ); - console.log( - "selectPlan", - routeParams.state?.planId, - routeParams.state?.productId, - (pricingPlans.selectedProduct as any).productId - ); } setStep(Steps.buy); - console.log("Buy step"); } }, [routeParams.state]); @@ -949,7 +942,6 @@ const PricingPlanCard = ({ regionalDiscount?.sku || `notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}` ]; - console.log(regionalDiscount?.sku); const price = pricingPlans?.getPrice( product as RNIap.Subscription, pricingPlans.hasTrialOffer(plan.id, product?.productId) ? 1 : 0, @@ -962,6 +954,7 @@ const PricingPlanCard = ({ ); useEffect(() => { + if (pricingPlans?.isGithubRelease) return; pricingPlans ?.getRegionalDiscount( plan.id, @@ -980,7 +973,7 @@ const PricingPlanCard = ({ pricingPlans.isSubscribed(); const isNotReady = - pricingPlans?.loadingPlans || (!price && !WebPlan?.price.gross); + pricingPlans?.loadingPlans || (!price && !WebPlan?.price?.gross); return ( - {pricingPlans?.loadingPlans || (!price && !WebPlan?.price.gross) ? ( + {pricingPlans?.loadingPlans || (!price && !WebPlan?.price?.gross) ? ( ) : ( @@ -1120,7 +1113,7 @@ const PricingPlanCard = ({ {isFreePlan ? "0.00" : price || - `${WebPlan?.price.currency} ${WebPlan?.price.gross}`}{" "} + `${WebPlan?.price?.currency} ${WebPlan?.price?.gross}`}{" "} /{strings.month()} diff --git a/apps/mobile/app/components/sheets/paywall/index.tsx b/apps/mobile/app/components/sheets/paywall/index.tsx index 8d043fd85..d279477cf 100644 --- a/apps/mobile/app/components/sheets/paywall/index.tsx +++ b/apps/mobile/app/components/sheets/paywall/index.tsx @@ -24,6 +24,7 @@ import AppIcon from "../../ui/AppIcon"; import { Button } from "../../ui/button"; import Heading from "../../ui/typography/heading"; import Paragraph from "../../ui/typography/paragraph"; +import SettingsService from "../../../services/settings"; const isGithubRelease = Config.GITHUB_RELEASE === "true"; const INDEX_TO_PLAN = { 1: "essential", @@ -55,11 +56,11 @@ export default function PaywallSheet(props: { }, []); const isSubscribedOnWeb = - (PremiumService.get() && + PremiumService.get() && + (pricingPlans.user?.subscription?.provider === + SubscriptionProvider.PADDLE || pricingPlans.user?.subscription?.provider === - SubscriptionProvider.PADDLE) || - pricingPlans.user?.subscription?.provider === - SubscriptionProvider.STREETWRITERS; + SubscriptionProvider.STREETWRITERS); const isCurrentPlatform = (pricingPlans.user?.subscription?.provider === SubscriptionProvider.APPLE && @@ -194,25 +195,28 @@ export default function PaywallSheet(props: { width: "100%" }} onPress={() => { - if ( - pricingPlans.user?.subscription.plan === - SubscriptionPlan.LEGACY_PRO || - !isCurrentPlatform - ) { - ToastManager.show({ - message: strings.cannotChangePlan(), - context: "local" - }); - return; + if (PremiumService.get()) { + if ( + pricingPlans.user?.subscription.plan === + SubscriptionPlan.LEGACY_PRO || + !isCurrentPlatform + ) { + ToastManager.show({ + message: strings.cannotChangePlan(), + context: "local" + }); + return; + } + + if (isSubscribedOnWeb) { + ToastManager.show({ + message: strings.changePlanOnWeb(), + context: "local" + }); + return; + } } - if (isSubscribedOnWeb) { - ToastManager.show({ - message: strings.changePlanOnWeb(), - context: "local" - }); - return; - } eSendEvent(eCloseSheet); if (!useUserStore.getState().user) { Navigation.navigate("Auth", { @@ -256,6 +260,7 @@ export default function PaywallSheet(props: { } PaywallSheet.present = (feature: FeatureResult) => { + if (SettingsService.getProperty("serverUrls")) return; presentSheet({ component: }); diff --git a/apps/mobile/app/components/sheets/plan-limits/index.tsx b/apps/mobile/app/components/sheets/plan-limits/index.tsx index 68ec57bcc..b7f50a9ea 100644 --- a/apps/mobile/app/components/sheets/plan-limits/index.tsx +++ b/apps/mobile/app/components/sheets/plan-limits/index.tsx @@ -20,6 +20,7 @@ import Paragraph from "../../ui/typography/paragraph"; import { SubscriptionPlan, SubscriptionProvider } from "@notesnook/core"; import { useUserStore } from "../../../stores/use-user-store"; import PremiumService from "../../../services/premium"; +import SettingsService from "../../../services/settings"; export function PlanLimits() { const { colors } = useThemeColors(); @@ -84,10 +85,11 @@ export function PlanLimits() { ))} - {(user?.subscription?.provider === SubscriptionProvider.PADDLE || + {((user?.subscription?.provider === SubscriptionProvider.PADDLE || user?.subscription?.provider === SubscriptionProvider.STREETWRITERS || !isCurrentPlatform) && - PremiumService.get() ? null : ( + PremiumService.get()) || + SettingsService.getProperty("serverUrls") ? null : (