mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-14 18:57:50 +01:00
Merge pull request #9041 from streetwriters/fix-subscription-type
Fix subscription type
This commit is contained in:
@@ -992,7 +992,7 @@ const PricingPlanCard = ({
|
||||
PremiumService.get() &&
|
||||
(pricingPlans?.user?.subscription?.productId ===
|
||||
(product as RNIap.Subscription)?.productId ||
|
||||
pricingPlans?.user?.subscription?.productId.startsWith(
|
||||
pricingPlans?.user?.subscription?.productId?.startsWith(
|
||||
(product as RNIap.Subscription)?.productId
|
||||
));
|
||||
pricingPlans?.selectPlan(
|
||||
|
||||
@@ -352,7 +352,7 @@ const ProductItem = (props: {
|
||||
props.pricingPlans.isSubscribed() &&
|
||||
(props.pricingPlans.user?.subscription?.productId ===
|
||||
(product as RNIap.Subscription)?.productId ||
|
||||
props.pricingPlans.user?.subscription?.productId.startsWith(
|
||||
props.pricingPlans.user?.subscription?.productId?.startsWith(
|
||||
(product as RNIap.Subscription)?.productId
|
||||
) ||
|
||||
props.pricingPlans.user?.subscription?.productId ===
|
||||
|
||||
@@ -103,7 +103,7 @@ export function PlanLimits() {
|
||||
|
||||
if (
|
||||
user?.subscription.plan !== SubscriptionPlan.FREE &&
|
||||
user?.subscription.productId.includes("5year")
|
||||
user?.subscription.productId?.includes("5year")
|
||||
) {
|
||||
ToastManager.show({
|
||||
message:
|
||||
|
||||
@@ -660,9 +660,25 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
|
||||
}
|
||||
}
|
||||
|
||||
function isSubscribedToPlan(planId: string) {
|
||||
if (!PremiumService.get()) return false;
|
||||
return user?.subscription?.productId?.includes(planId);
|
||||
}
|
||||
|
||||
function isSubscribedToProduct(productId: string) {
|
||||
if (!PremiumService.get()) return false;
|
||||
return (
|
||||
user?.subscription?.productId &&
|
||||
(user?.subscription?.productId === productId ||
|
||||
user?.subscription?.productId?.startsWith(productId))
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
currentPlan: pricingPlans.find((p) => p.id === currentPlan),
|
||||
pricingPlans: plans,
|
||||
isSubscribedToPlan,
|
||||
isSubscribedToProduct,
|
||||
getStandardPrice: getLocalizedPrice,
|
||||
loadingPlans,
|
||||
loading,
|
||||
|
||||
@@ -118,7 +118,8 @@ export const settingsGroups: SettingSection[] = [
|
||||
if (
|
||||
(user.subscription?.provider === SubscriptionProvider.GOOGLE ||
|
||||
user.subscription?.provider === SubscriptionProvider.APPLE) &&
|
||||
isCurrentPlatform
|
||||
isCurrentPlatform &&
|
||||
user?.subscription?.productId
|
||||
) {
|
||||
RNIap.deepLinkToSubscriptions({
|
||||
sku: user?.subscription.productId
|
||||
@@ -142,13 +143,18 @@ export const settingsGroups: SettingSection[] = [
|
||||
"dddd, MMMM D, YYYY h:mm A"
|
||||
);
|
||||
|
||||
if (user.subscription?.plan !== SubscriptionPlan.FREE) {
|
||||
if (
|
||||
user.subscription?.plan !== SubscriptionPlan.FREE &&
|
||||
user.subscription?.productId
|
||||
) {
|
||||
const status = user.subscription?.status;
|
||||
return status === SubscriptionStatus.TRIAL
|
||||
? strings.trialEndsOn(
|
||||
dayjs(user?.subscription?.start)
|
||||
.add(
|
||||
user?.subscription?.productId.includes("monthly") ? 7 : 14
|
||||
user?.subscription?.productId?.includes("monthly")
|
||||
? 7
|
||||
: 14
|
||||
)
|
||||
.format("dddd, MMMM D, YYYY h:mm A")
|
||||
)
|
||||
|
||||
4
apps/mobile/package-lock.json
generated
4
apps/mobile/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@notesnook/mobile",
|
||||
"version": "3.3.7",
|
||||
"version": "3.3.9",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@notesnook/mobile",
|
||||
"version": "3.3.7",
|
||||
"version": "3.3.9",
|
||||
"hasInstallScript": true,
|
||||
"license": "GPL-3.0-or-later",
|
||||
"workspaces": [
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -147,7 +147,7 @@ export const BuyDialog = DialogManager.register(function BuyDialog(
|
||||
</Text>
|
||||
</Flex>
|
||||
<PlansList
|
||||
selectedPlan={user?.subscription.productId}
|
||||
selectedPlan={user?.subscription?.productId}
|
||||
recommendedPlan={SubscriptionPlan.PRO}
|
||||
onPlanSelected={(plan) => selectPlan(plan)}
|
||||
/>
|
||||
|
||||
@@ -42,7 +42,7 @@ import { useStore as useUserStore } from "../../stores/user-store";
|
||||
import { getCurrencySymbol } from "../../common/currencies";
|
||||
|
||||
type PlansListProps = {
|
||||
selectedPlan?: string;
|
||||
selectedPlan?: string | null;
|
||||
loadAllPlans?: boolean;
|
||||
ignoreTrial?: boolean;
|
||||
recommendedPlan?: SubscriptionPlan;
|
||||
|
||||
@@ -604,7 +604,7 @@ export type User = {
|
||||
cancelURL: string | null;
|
||||
expiry: number;
|
||||
trialExpiry?: number;
|
||||
productId: string;
|
||||
productId: string | null;
|
||||
provider: SubscriptionProvider;
|
||||
start: number;
|
||||
plan: SubscriptionPlan;
|
||||
|
||||
Reference in New Issue
Block a user