Skip to content

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

mobile: fix crash in settings on incomplete user account creation

ammarahm-edc5a53e42ec6c
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index 013a902a6..0c8fc5b16 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -82,7 +82,7 @@ export const settingsGroups: SettingSection[] = [
const user = current as User;
const isBasic = user.subscription?.type === SUBSCRIPTION_STATUS.BASIC;
const isTrial = user.subscription?.type === SUBSCRIPTION_STATUS.TRIAL;
- return isBasic
+ return isBasic || !user.subscription?.type
? "Subscribe to Pro"
: isTrial
? "Your free trial has started"
diff --git a/apps/mobile/app/screens/settings/user-section.js b/apps/mobile/app/screens/settings/user-section.js
index 3d3b960d2..b6b8eed0a 100644
--- a/apps/mobile/app/screens/settings/user-section.js
+++ b/apps/mobile/app/screens/settings/user-section.js
@@ -39,21 +39,7 @@ export const getTimeLeft = (t2) => {
const SettingsUserSection = ({ item }) => {
const colors = useThemeStore((state) => state.colors);
-
const user = useUserStore((state) => state.user);
- // const subscriptionDaysLeft =
- // user && getTimeLeft(parseInt(user.subscription?.expiry));
- // const isExpired = user && subscriptionDaysLeft.time < 0;
- // const expiryDate = dayjs(user?.subscription?.expiry).format('MMMM D, YYYY');
- // const startDate = dayjs(user?.subscription?.start).format('MMMM D, YYYY');
- // const monthlyPlan = usePricing('monthly');
- // const isBasic = user?.subscription?.type === SUBSCRIPTION_STATUS.BASIC;
- // const isTrial = user?.subscription?.type === SUBSCRIPTION_STATUS.TRIAL;
- // const isPro = user?.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM;
- // const isNotPro =
- // user?.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM &&
- // user?.subscription?.type !== SUBSCRIPTION_STATUS.BETA;
-
const lastSynced = useUserStore((state) => state.lastSynced);
return (
@@ -126,7 +112,7 @@ const SettingsUserSection = ({ item }) => {
<Heading color={colors.accent} size={SIZE.xs + 1}>
{SUBSCRIPTION_STATUS_STRINGS[
user.subscription?.type
- ].toUpperCase()}
+ ]?.toUpperCase() || "Basic"}
</Heading>
<Paragraph color={colors.heading} size={SIZE.sm}>
@@ -143,92 +129,6 @@ const SettingsUserSection = ({ item }) => {
</View>
</View>
</View>
-
- {/* {isNotPro ? (
- <Button
- height={30}
- style={{
- borderRadius: 100,
- paddingHorizontal: 12
- }}
- fontSize={SIZE.xs}
- type="accent"
- title={`GET PRO (${monthlyPlan?.product?.localizedPrice} / mo)`}
- />
- ) : null} */}
-
- {/* <View>
- {user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC ? (
- <View>
- <Seperator />
- <Paragraph
- size={SIZE.lg}
- style={{
- textAlign: 'center'
- }}
- color={
- (subscriptionDaysLeft.time > 5 && !subscriptionDaysLeft.isHour) ||
- user.subscription?.type !== 6
- ? colors.accent
- : colors.red
- }
- >
- {isExpired
- ? 'Your subscription has ended.'
- : user.subscription?.type === 1
- ? `Your free trial has started`
- : `Subscribed to Notesnook Pro`}
- </Paragraph>
- <Paragraph
- style={{
- textAlign: 'center'
- }}
- color={colors.pri}
- >
- {user.subscription?.type === 2
- ? 'You signed up on ' + startDate
- : user.subscription?.type === 1
- ? 'Your free trial will end on ' + expiryDate
- : user.subscription?.type === 6
- ? subscriptionDaysLeft.time < -3
- ? 'Your subscription has ended'
- : 'Your account will be downgraded to Basic in 3 days'
- : user.subscription?.type === 7
- ? `Your subscription will end on ${expiryDate}.`
- : user.subscription?.type === 5
- ? `Your subscription will renew on ${expiryDate}.`
- : null}
- </Paragraph>
- </View>
- ) : null}
- </View> */}
-
- {/* {user?.subscription?.provider &&
- user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&
- user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC &&
- SUBSCRIPTION_PROVIDER[user?.subscription?.provider] ? (
- <Button
- title={SUBSCRIPTION_PROVIDER[user?.subscription?.provider]?.title}
- onPress={() => {
- presentSheet({
- title: SUBSCRIPTION_PROVIDER[user?.subscription?.provider].title,
- paragraph: SUBSCRIPTION_PROVIDER[user?.subscription?.provider].desc
- });
- }}
- style={{
- alignSelf: 'flex-end',
- marginTop: 10,
- borderRadius: 3,
- zIndex: 10
- }}
- fontSize={11}
- textStyle={{
- fontWeight: 'normal'
- }}
- height={20}
- type="accent"
- />
- ) : null} */}
</View>
</View>