Skip to content

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

fix crash on logout

ammarahm-edff954bc3dd52
diff --git a/apps/mobile/AppRootEvents.js b/apps/mobile/AppRootEvents.js
index 7de2fd7c8..067e86c9e 100644
--- a/apps/mobile/AppRootEvents.js
+++ b/apps/mobile/AppRootEvents.js
@@ -341,7 +341,6 @@ export const AppRootEvents = React.memo(
const setCurrentUser = async login => {
try {
let user = await db.user.getUser();
- console.log(user, 'called user set current');
if ((await MMKV.getItem('loginSessionHasExpired')) === 'expired') {
setUser(user);
return;
diff --git a/apps/mobile/initializer.root.js b/apps/mobile/initializer.root.js
index 3157d1b2c..a87039ece 100644
--- a/apps/mobile/initializer.root.js
+++ b/apps/mobile/initializer.root.js
@@ -313,7 +313,7 @@ const NativeStack = React.memo(
height: '100%',
width: fullscreen ? 0 : widths[deviceMode].b
}}>
- {deviceMode === 'mobile' && (
+ {deviceMode === 'mobile' ? (
<Animated.View
style={{
position: 'absolute',
@@ -330,7 +330,7 @@ const NativeStack = React.memo(
}}
ref={overlayRef}
/>
- )}
+ ) : null}
<NavigatorStack />
</View>,
@@ -346,7 +346,7 @@ const NativeStack = React.memo(
height: '100%',
backgroundColor: colors.bg
}}>
- {deviceMode && (
+ {deviceMode ? (
<CustomTabs
ref={tabBarRef}
dimensions={dimensions}
@@ -363,7 +363,7 @@ const NativeStack = React.memo(
onScroll={onScroll}
onChangeTab={onChangeTab}
/>
- )}
+ ) : null}
</View>
);
},
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 6b241019a..db69bb304 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -835,7 +835,7 @@ export const ActionSheetComponent = ({
))
: null}
- {note.type === 'note' && isPublished && (
+ {note.type === 'note' && isPublished ? (
<Button
title="Published"
type="shade"
@@ -849,7 +849,7 @@ export const ActionSheetComponent = ({
paddingHorizontal: 12
}}
/>
- )}
+ ) : null}
{note.type !== 'note' || refreshing ? null : (
<Button
onPress={async () => await Sync.run('local')}
diff --git a/apps/mobile/src/components/Button/index.js b/apps/mobile/src/components/Button/index.js
index e51ace45c..19d8b518c 100644
--- a/apps/mobile/src/components/Button/index.js
+++ b/apps/mobile/src/components/Button/index.js
@@ -1,11 +1,10 @@
import React from 'react';
-import {ActivityIndicator} from 'react-native';
+import { ActivityIndicator } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import {useTracked} from '../../provider';
-import {BUTTON_TYPES, showTooltip} from '../../utils';
-import {ph, pv, SIZE} from '../../utils/SizeUtils';
-import {PressableButton} from '../PressableButton';
-import Heading from '../Typography/Heading';
+import { useTracked } from '../../provider';
+import { BUTTON_TYPES, showTooltip } from '../../utils';
+import { ph, SIZE } from '../../utils/SizeUtils';
+import { PressableButton } from '../PressableButton';
import Paragraph from '../Typography/Paragraph';
/**
diff --git a/apps/mobile/src/components/Container/ContainerTopSection.js b/apps/mobile/src/components/Container/ContainerTopSection.js
index cb746c093..ad1eaec54 100644
--- a/apps/mobile/src/components/Container/ContainerTopSection.js
+++ b/apps/mobile/src/components/Container/ContainerTopSection.js
@@ -8,7 +8,7 @@ export const ContainerTopSection = ({children}) => {
const {colors} = state;
const selectionMode = useSelectionStore(state => state.selectionMode);
- return !selectionMode && (
+ return !selectionMode ? (
<View
style={{
backgroundColor: colors.bg,
@@ -17,5 +17,5 @@ export const ContainerTopSection = ({children}) => {
}}>
{children}
</View>
- );
+ ) : null
};
diff --git a/apps/mobile/src/components/Dialog/DialogButtons.js b/apps/mobile/src/components/Dialog/DialogButtons.js
index 37b143ca5..e7b3e8aae 100644
--- a/apps/mobile/src/components/Dialog/DialogButtons.js
+++ b/apps/mobile/src/components/Dialog/DialogButtons.js
@@ -52,7 +52,7 @@ const DialogButtons = ({
type="gray"
title={negativeTitle}
/>
- {onPressPositive && (
+ {onPressPositive ? (
<Button
onPress={onPressPositive}
fontSize={SIZE.md}
@@ -63,7 +63,7 @@ const DialogButtons = ({
type={positiveType || "transparent"}
title={positiveTitle}
/>
- )}
+ ) : null}
</View>
</View>
);
diff --git a/apps/mobile/src/components/Dialog/DialogHeader.js b/apps/mobile/src/components/Dialog/DialogHeader.js
index 24a2d37a4..350b7c272 100644
--- a/apps/mobile/src/components/Dialog/DialogHeader.js
+++ b/apps/mobile/src/components/Dialog/DialogHeader.js
@@ -31,7 +31,7 @@ const DialogHeader = ({icon, title, paragraph, button, paragraphColor}) => {
}}>
<Heading size={SIZE.xl}>{title}</Heading>
- {button && (
+ {button ? (
<Button
onPress={button.onPress}
style={{
@@ -42,7 +42,7 @@ const DialogHeader = ({icon, title, paragraph, button, paragraphColor}) => {
type="accent"
height={25}
/>
- )}
+ ) : null}
</View>
{paragraph ? (
diff --git a/apps/mobile/src/components/Premium/PremiumComponent.js b/apps/mobile/src/components/Premium/PremiumComponent.js
index a4fac816c..9279b21aa 100644
--- a/apps/mobile/src/components/Premium/PremiumComponent.js
+++ b/apps/mobile/src/components/Premium/PremiumComponent.js
@@ -318,7 +318,7 @@ export const PremiumComponent = ({close, promo, getRef}) => {
height={normalize(60)}
width="100%"
/>
- {user && (
+ {user ? (
<Button
height={35}
style={{
@@ -368,7 +368,7 @@ export const PremiumComponent = ({close, promo, getRef}) => {
}}
title="I have a promo code"
/>
- )}
+ ) : null}
</>
) : (
<Paragraph
diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/ProgressDialog/index.js
index 87b686d3f..b00725084 100644
--- a/apps/mobile/src/components/ProgressDialog/index.js
+++ b/apps/mobile/src/components/ProgressDialog/index.js
@@ -71,7 +71,7 @@ const ProgressDialog = () => {
{dialogData?.title && <Heading> {dialogData?.title}</Heading>}
- {dialogData?.paragraph && (
+ {dialogData?.paragraph ? (
<Paragraph style={{textAlign: 'center'}}>
{dialogData?.paragraph}
{!dialogData?.noProgress ? (
@@ -81,7 +81,7 @@ const ProgressDialog = () => {
</Paragraph>
) : null}
</Paragraph>
- )}
+ ) : null}
</View>
{dialogData.component}
diff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.js
index fe832ffca..266289129 100644
--- a/apps/mobile/src/components/VaultDialog/index.js
+++ b/apps/mobile/src/components/VaultDialog/index.js
@@ -833,11 +833,11 @@ export class VaultDialog extends Component {
{this.state.biometricUnlock &&
!this.state.isBiometryEnrolled &&
- novault && (
+ novault ? (
<Paragraph>
Unlock with password once to enable biometric access.
</Paragraph>
- )}
+ ) : null}
{this.state.isBiometryAvailable &&
!this.state.fingerprintAccess &&
diff --git a/apps/mobile/src/navigation/NavigatorStack.js b/apps/mobile/src/navigation/NavigatorStack.js
index d94f2c581..9172e6a58 100644
--- a/apps/mobile/src/navigation/NavigatorStack.js
+++ b/apps/mobile/src/navigation/NavigatorStack.js
@@ -60,7 +60,7 @@ export const NavigatorStack = React.memo(
onStateChange={onStateChange}
independent={true}
ref={rootNavigatorRef}>
- {render && (
+ {render ? (
<Stack.Navigator
initialRouteName={settings.homepage}
screenOptions={{
@@ -78,7 +78,7 @@ export const NavigatorStack = React.memo(
<Stack.Screen name="Settings" component={Settings} />
<Stack.Screen name="Search" component={Search} />
</Stack.Navigator>
- )}
+ ) : null}
</NavigationContainer>
</Container>
);
diff --git a/apps/mobile/src/services/Sync.js b/apps/mobile/src/services/Sync.js
index b3ca04aeb..329aa649e 100644
--- a/apps/mobile/src/services/Sync.js
+++ b/apps/mobile/src/services/Sync.js
@@ -9,11 +9,6 @@ import {eSendEvent, ToastEvent} from './EventManager';
const run = async (context = 'global', forced) => {
let userstore = useUserStore.getState();
if (userstore.syncing) {
- ToastEvent.show({
- heading: 'Sync running already',
- message:"Please wait a few moments",
- type: 'success'
- });
return;
}
userstore.setSyncing(true);
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 3a6c35479..b5a9e16a6 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -33,7 +33,8 @@ export const Notes = ({route, navigation}) => {
const [notes, setNotes] = useState([]);
const loading = useNoteStore(state => state.loading);
let params = route.params ? route.params : null;
- const alias = param.type === "tag" ? db.tags.alias(params.title) : db.colors.alias(params.title)
+ const alias = params.type === "tag" ? db.tags.alias(params.title) : params.type === "color" ? db.colors.alias(params.title) : params.title
+
let ranAfterInteractions = false;
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index 35bbaa905..13a0278f1 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -1,11 +1,5 @@
import dayjs from 'dayjs';
-import React, {
- createRef,
- useCallback,
- useEffect,
- useRef,
- useState
-} from 'react';
+import React, {useCallback, useEffect, useRef, useState} from 'react';
import {
Appearance,
Linking,
@@ -21,6 +15,7 @@ import AnimatedProgress from 'react-native-reanimated-progress-bar';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import ToggleSwitch from 'toggle-switch-react-native';
import {Button} from '../../components/Button';
+import {Button as MButton} from '../../components/Button/index';
import {ContainerTopSection} from '../../components/Container/ContainerTopSection';
import BaseDialog from '../../components/Dialog/base-dialog';
import DialogButtons from '../../components/Dialog/dialog-buttons';
@@ -91,8 +86,6 @@ import {tabBarRef} from '../../utils/Refs';
import {pv, SIZE} from '../../utils/SizeUtils';
import Storage from '../../utils/storage';
import {sleep} from '../../utils/TimeUtils';
-import {Button as MButton} from '../../components/Button/index';
-import Share from 'react-native-share';
const format = ver => {
let parts = ver.toString().split('');
@@ -298,39 +291,6 @@ export const Settings = ({navigation}) => {
<SettingsAppearanceSection />
<SettingsPrivacyAndSecurity />
- {/**
- * <View
- style={{
- alignItems: 'center',
- width: '95%',
- borderRadius: 5,
- backgroundColor: colors.nav,
- alignSelf: 'center',
- padding: 12,
- marginVertical:6
- }}>
- <Heading size={18}>Invite code: XZA8G</Heading>
- <Paragraph
- style={{
- textAlign: 'center'
- }}>
- Invite your friends to Notesnook and on every sign up, you will get 7 days of
- Notesnook Pro for free.
- </Paragraph>
- <Seperator />
- <MButton
- fontSize={SIZE.md}
- onPress={() => {
- Share.open({
- title:"Download Notesnook",
- message:"Download Notesnook",
- failOnCancel:false
- })
- }}
- height={40} width="100%" title="Invite a friend" type="accent" />
- </View>
- */}
-
<SettingsBackupAndRestore />
<SectionHeader
@@ -456,15 +416,13 @@ let passwordValue = null;
const AccoutLogoutSection = () => {
const [state, dispatch] = useTracked();
const {colors} = state;
-
const user = useUserStore(state => state.user);
const [visible, setVisible] = useState(false);
const [deleteAccount, setDeleteAccount] = useState(false);
const [loading, setLoading] = useState(false);
const pwdInput = useRef();
- return (
- user && (
+ return !user ? null : (
<>
{loading && (
<BaseDialog visible={true}>
@@ -659,7 +617,6 @@ const AccoutLogoutSection = () => {
</PressableButton>
</>
)
- );
};
const CustomButton = ({
@@ -765,10 +722,10 @@ const SettingsUserSection = () => {
const manageSubscription = () => {
if (
- user.subscription.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&
+ user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&
Platform.OS === 'android'
) {
- if (user.subscription.provider === 3) {
+ if (user.subscription?.provider === 3) {
ToastEvent.show({
heading: 'Subscribed on web',
message: 'Open your web browser to manage your subscription.',
@@ -857,12 +814,12 @@ const SettingsUserSection = () => {
paddingVertical: 2.5
}}>
<Heading color={colors.accent} size={SIZE.sm}>
- {SUBSCRIPTION_STATUS_STRINGS[user.subscription.type]}
+ {SUBSCRIPTION_STATUS_STRINGS[user.subscription?.type]}
</Heading>
</View>
</View>
<View>
- {user.subscription.type !== SUBSCRIPTION_STATUS.BASIC ? (
+ {user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC ? (
<View>
<Seperator />
<Paragraph
@@ -870,7 +827,7 @@ const SettingsUserSection = () => {
color={
(subscriptionDaysLeft.time > 5 &&
!subscriptionDaysLeft.isHour) ||
- user.subscription.type !== 6
+ user.subscription?.type !== 6
? colors.accent
: colors.red
}>
@@ -881,17 +838,17 @@ const SettingsUserSection = () => {
} remaining`}
</Paragraph>
<Paragraph color={colors.pri}>
- {user.subscription.type === 2
+ {user.subscription?.type === 2
? 'You signed up on ' + startDate
- : user.subscription.type === 1
+ : user.subscription?.type === 1
? 'Your trial period started on ' + startDate
- : user.subscription.type === 6
+ : 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
+ : user.subscription?.type === 7
? `Your subscription will end on ${expiryDate}.`
- : user.subscription.type === 5
+ : user.subscription?.type === 5
? `Your subscription will auto renew on ${expiryDate}.`
: null}
</Paragraph>
@@ -899,8 +856,8 @@ const SettingsUserSection = () => {
) : null}
{user.isEmailConfirmed &&
- user.subscription.type !== SUBSCRIPTION_STATUS.PREMIUM &&
- user.subscription.type !== SUBSCRIPTION_STATUS.BETA && (
+ user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM &&
+ user.subscription?.type !== SUBSCRIPTION_STATUS.BETA && (
<>
<Seperator />
<Button
@@ -911,15 +868,15 @@ const SettingsUserSection = () => {
}}
fontSize={SIZE.md}
title={
- user.subscription.provider === 3 &&
- user.subscription.type ===
+ user.subscription?.provider === 3 &&
+ user.subscription?.type ===
SUBSCRIPTION_STATUS.PREMIUM_CANCELLED
? 'Manage subscription from desktop app'
- : user.subscription.type ===
+ : user.subscription?.type ===
SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&
Platform.OS === 'android'
? `Resubscribe from Google Playstore`
- : user.subscription.type ===
+ : user.subscription?.type ===
SUBSCRIPTION_STATUS.PREMIUM_EXPIRED
? `Resubscribe to Notesnook Pro (${
PremiumService.getMontlySub().localizedPrice
@@ -936,8 +893,8 @@ const SettingsUserSection = () => {
</View>
{user?.subscription?.provider &&
- user.subscription.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&
- user.subscription.type !== SUBSCRIPTION_STATUS.BASIC &&
+ user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&
+ user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC &&
SUBSCRIPTION_PROVIDER[user?.subscription?.provider] ? (
<Button
title={
@@ -1733,6 +1690,7 @@ export const SettingsBackupAndRestore = ({isSheet}) => {
new: true
}
];
+
const backupItemsList = [
{
name: 'Backup now',