Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix crash on pricing plans page on ios

Ammar Ahmed0dc2d1473626
diff --git a/apps/mobile/app/components/premium/pricing-item.tsx b/apps/mobile/app/components/premium/pricing-item.tsx
index 56a2e5e85..a06a6c657 100644
--- a/apps/mobile/app/components/premium/pricing-item.tsx
+++ b/apps/mobile/app/components/premium/pricing-item.tsx
@@ -70,10 +70,11 @@ export const PricingItem = ({
<Paragraph size={SIZE.sm}>
<Heading size={SIZE.lg - 2}>
{Platform.OS === "android"
- ? (product.data as RNIap.SubscriptionAndroid)
+ ? (product.data as RNIap.SubscriptionAndroid | undefined)
?.subscriptionOfferDetails[0].pricingPhases
- .pricingPhaseList?.[0].formattedPrice
- : (product.data as RNIap.SubscriptionIOS)?.localizedPrice}
+ .pricingPhaseList?.[0]?.formattedPrice
+ : (product.data as RNIap.SubscriptionIOS | undefined)
+ ?.localizedPrice}
</Heading>
{product?.type === "yearly" || product?.offerType === "yearly"
? "/year"
diff --git a/apps/mobile/app/components/premium/pricing-plans.tsx b/apps/mobile/app/components/premium/pricing-plans.tsx
index c22ca30e8..c7be83ffd 100644
--- a/apps/mobile/app/components/premium/pricing-plans.tsx
+++ b/apps/mobile/app/components/premium/pricing-plans.tsx
@@ -245,12 +245,12 @@ export const PricingPlans = ({
size={SIZE.lg}
>
{(Platform.OS === "android"
- ? (monthlyPlan?.product as RNIap.SubscriptionAndroid)
- ?.subscriptionOfferDetails[0].pricingPhases
- .pricingPhaseList?.[0].formattedPrice
- : (monthlyPlan?.product as RNIap.SubscriptionIOS)
- .localizedPrice) ||
- (PremiumService.getMontlySub() as any).localizedPrice}
+ ? (monthlyPlan?.product as RNIap.SubscriptionAndroid | undefined)
+ ?.subscriptionOfferDetails[0]?.pricingPhases
+ .pricingPhaseList?.[0]?.formattedPrice
+ : (monthlyPlan?.product as RNIap.SubscriptionIOS | undefined)
+ ?.localizedPrice) ||
+ (PremiumService.getMontlySub() as any)?.localizedPrice}
/ mo
</Paragraph>
<Button
@@ -314,8 +314,8 @@ export const PricingPlans = ({
>
{Platform.OS === "android"
? (product.data as RNIap.SubscriptionAndroid)
- ?.subscriptionOfferDetails[1].pricingPhases
- .pricingPhaseList?.[1].formattedPrice
+ ?.subscriptionOfferDetails[1]?.pricingPhases
+ .pricingPhaseList?.[1]?.formattedPrice
: (product.data as RNIap.SubscriptionIOS)?.localizedPrice}
</Paragraph>{" "}
for {product.cycleText}
diff --git a/apps/mobile/app/screens/settings/subscription.js b/apps/mobile/app/screens/settings/subscription.js
index 56e795c9b..a86ea6398 100644
--- a/apps/mobile/app/screens/settings/subscription.js
+++ b/apps/mobile/app/screens/settings/subscription.js
@@ -91,7 +91,7 @@ export const Subscription = () => {
function getPrice() {
return Platform.OS === "android"
? monthlyPlan?.product?.subscriptionOfferDetails[0].pricingPhases
- .pricingPhaseList?.[0].formattedPrice
+ .pricingPhaseList?.[0]?.formattedPrice
: monthlyPlan?.product?.localizedPrice;
}