mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
mobile: add null checks
This commit is contained in:
@@ -56,15 +56,16 @@ export default function PaywallSheet<Tid extends FeatureId>(props: {
|
|||||||
|
|
||||||
const isSubscribedOnWeb =
|
const isSubscribedOnWeb =
|
||||||
(PremiumService.get() &&
|
(PremiumService.get() &&
|
||||||
pricingPlans.user?.subscription.provider ===
|
pricingPlans.user?.subscription?.provider ===
|
||||||
SubscriptionProvider.PADDLE) ||
|
SubscriptionProvider.PADDLE) ||
|
||||||
pricingPlans.user?.subscription.provider ===
|
pricingPlans.user?.subscription?.provider ===
|
||||||
SubscriptionProvider.STREETWRITERS;
|
SubscriptionProvider.STREETWRITERS;
|
||||||
|
|
||||||
const isCurrentPlatform =
|
const isCurrentPlatform =
|
||||||
(pricingPlans.user?.subscription.provider === SubscriptionProvider.APPLE &&
|
(pricingPlans.user?.subscription?.provider === SubscriptionProvider.APPLE &&
|
||||||
Platform.OS === "ios") ||
|
Platform.OS === "ios") ||
|
||||||
(pricingPlans.user?.subscription.provider === SubscriptionProvider.GOOGLE &&
|
(pricingPlans.user?.subscription?.provider ===
|
||||||
|
SubscriptionProvider.GOOGLE &&
|
||||||
Platform.OS === "android");
|
Platform.OS === "android");
|
||||||
|
|
||||||
return !pricingPlans.currentPlan ? null : (
|
return !pricingPlans.currentPlan ? null : (
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ export function PlanLimits() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const isCurrentPlatform =
|
const isCurrentPlatform =
|
||||||
(user?.subscription.provider === SubscriptionProvider.APPLE &&
|
(user?.subscription?.provider === SubscriptionProvider.APPLE &&
|
||||||
Platform.OS === "ios") ||
|
Platform.OS === "ios") ||
|
||||||
(user?.subscription.provider === SubscriptionProvider.GOOGLE &&
|
(user?.subscription?.provider === SubscriptionProvider.GOOGLE &&
|
||||||
Platform.OS === "android");
|
Platform.OS === "android");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -84,8 +84,8 @@ export function PlanLimits() {
|
|||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{(user?.subscription.provider === SubscriptionProvider.PADDLE ||
|
{(user?.subscription?.provider === SubscriptionProvider.PADDLE ||
|
||||||
user?.subscription.provider === SubscriptionProvider.STREETWRITERS ||
|
user?.subscription?.provider === SubscriptionProvider.STREETWRITERS ||
|
||||||
!isCurrentPlatform) &&
|
!isCurrentPlatform) &&
|
||||||
PremiumService.get() ? null : (
|
PremiumService.get() ? null : (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -100,9 +100,9 @@ export const settingsGroups: SettingSection[] = [
|
|||||||
strings.subscriptionProviderInfo[user?.subscription?.provider];
|
strings.subscriptionProviderInfo[user?.subscription?.provider];
|
||||||
|
|
||||||
const isCurrentPlatform =
|
const isCurrentPlatform =
|
||||||
(user.subscription.provider === SubscriptionProvider.APPLE &&
|
(user.subscription?.provider === SubscriptionProvider.APPLE &&
|
||||||
Platform.OS === "ios") ||
|
Platform.OS === "ios") ||
|
||||||
(user.subscription.provider === SubscriptionProvider.GOOGLE &&
|
(user.subscription?.provider === SubscriptionProvider.GOOGLE &&
|
||||||
Platform.OS === "android");
|
Platform.OS === "android");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -132,8 +132,8 @@ 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) {
|
||||||
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)
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ const SettingsUserSection = ({ item }) => {
|
|||||||
const total = user?.totalStorage || 0;
|
const total = user?.totalStorage || 0;
|
||||||
|
|
||||||
const isCurrentPlatform =
|
const isCurrentPlatform =
|
||||||
(user?.subscription.provider === SubscriptionProvider.APPLE &&
|
(user?.subscription?.provider === SubscriptionProvider.APPLE &&
|
||||||
Platform.OS === "ios") ||
|
Platform.OS === "ios") ||
|
||||||
(user?.subscription.provider === SubscriptionProvider.GOOGLE &&
|
(user?.subscription?.provider === SubscriptionProvider.GOOGLE &&
|
||||||
Platform.OS === "android");
|
Platform.OS === "android");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -328,7 +328,7 @@ const SettingsUserSection = ({ item }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Paragraph size={AppFontSize.sm}>
|
<Paragraph size={AppFontSize.sm}>
|
||||||
{planToDisplayName(user.subscription.plan)}
|
{planToDisplayName(user.subscription?.plan)}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph
|
<Paragraph
|
||||||
color={colors.secondary.paragraph}
|
color={colors.secondary.paragraph}
|
||||||
@@ -339,14 +339,14 @@ const SettingsUserSection = ({ item }) => {
|
|||||||
</Paragraph>
|
</Paragraph>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
{(user.subscription.provider === SubscriptionProvider.PADDLE ||
|
{(user.subscription?.provider === SubscriptionProvider.PADDLE ||
|
||||||
user.subscription.provider ===
|
user.subscription?.provider ===
|
||||||
SubscriptionProvider.STREETWRITERS ||
|
SubscriptionProvider.STREETWRITERS ||
|
||||||
!isCurrentPlatform) &&
|
!isCurrentPlatform) &&
|
||||||
PremiumService.get() ? null : (
|
PremiumService.get() ? null : (
|
||||||
<Button
|
<Button
|
||||||
title={
|
title={
|
||||||
user.subscription.plan !== SubscriptionPlan.FREE
|
user.subscription?.plan !== SubscriptionPlan.FREE
|
||||||
? strings.changePlan()
|
? strings.changePlan()
|
||||||
: strings.upgradePlan()
|
: strings.upgradePlan()
|
||||||
}
|
}
|
||||||
@@ -362,8 +362,9 @@ const SettingsUserSection = ({ item }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
user.subscription.plan !== SubscriptionPlan.FREE &&
|
user.subscription?.plan !== SubscriptionPlan.FREE &&
|
||||||
user.subscription.productId.includes("5year")
|
user.subscription?.productId &&
|
||||||
|
user.subscription?.productId.includes("5year")
|
||||||
) {
|
) {
|
||||||
ToastManager.show({
|
ToastManager.show({
|
||||||
message:
|
message:
|
||||||
|
|||||||
Reference in New Issue
Block a user