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