Skip to content

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

do not load notes before db.notes init is not cplt

ammarahm-edfcbce7124547
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index d81fc11c6..9e86dd9d4 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -41,6 +41,7 @@ import {
eOpenSideMenu,
eShowGetPremium,
eStartSyncer,
+ refreshNotesPage,
} from './src/utils/Events';
import {MMKV} from './src/utils/mmkv';
import {tabBarRef} from './src/utils/Refs';
@@ -319,6 +320,8 @@ const App = () => {
sleep(500).then(() => (appInit = true));
db.notes.init().then(() => {
dispatch({type: Actions.NOTES});
+ dispatch({type: Actions.FAVORITES});
+ eSendEvent(refreshNotesPage)
dispatch({type: Actions.LOADING, loading: false});
SettingsService.setAppLoaded();
});
@@ -345,7 +348,6 @@ const App = () => {
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
dispatch({type: Actions.ALL});
await startSyncer();
-
} else {
setLoginMessage(dispatch);
}
diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/ProgressDialog/index.js
index 0e881b460..ba0bd6af8 100644
--- a/apps/mobile/src/components/ProgressDialog/index.js
+++ b/apps/mobile/src/components/ProgressDialog/index.js
@@ -1,15 +1,16 @@
-import React, { useEffect, useState } from 'react';
-import { ActivityIndicator, View } from 'react-native';
-import { useTracked } from '../../provider';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import { eCloseProgressDialog, eOpenProgressDialog } from '../../utils/Events';
+import React, {useEffect, useState} from 'react';
+import {ActivityIndicator, View} from 'react-native';
+import {useTracked} from '../../provider';
+import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
+import {eCloseProgressDialog, eOpenProgressDialog} from '../../utils/Events';
+import {Button} from '../Button';
import BaseDialog from '../Dialog/base-dialog';
import DialogContainer from '../Dialog/dialog-container';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
const ProgressDialog = () => {
- const [state, ] = useTracked();
+ const [state] = useTracked();
const {colors} = state;
const [visible, setVisible] = useState(false);
const [dialogData, setDialogData] = useState({
@@ -35,7 +36,14 @@ const ProgressDialog = () => {
};
return !visible ? null : (
- <BaseDialog visible={true}>
+ <BaseDialog
+ visible={true}
+ onRequestClose={() => {
+ if (dialogData.noProgress) {
+ setVisible(false);
+ setDialogData(null);
+ }
+ }}>
<DialogContainer>
<View
style={{
@@ -43,16 +51,23 @@ const ProgressDialog = () => {
alignItems: 'center',
marginBottom: 10,
}}>
- <Heading> {dialogData.title}</Heading>
+ <Heading> {dialogData?.title}</Heading>
<Paragraph style={{textAlign: 'center'}}>
-
- <Paragraph color={colors.errorText}>
- {' '}
- Do not close the app.
- </Paragraph>
+ {dialogData?.paragraph}
+ {!dialogData?.noProgress ? (
+ <Paragraph color={colors.errorText}>
+ {' '}
+ Do not close the app.
+ </Paragraph>
+ ) : null}
</Paragraph>
</View>
- <ActivityIndicator color={colors.accent} />
+ {!dialogData?.noProgress ? (
+ <ActivityIndicator color={colors.accent} />
+ ) : null}
+ {dialogData?.action ? (
+ <Button type="transparent" title="Resend Confirmation Link" />
+ ) : null}
</DialogContainer>
</BaseDialog>
);
diff --git a/apps/mobile/src/services/Message.js b/apps/mobile/src/services/Message.js
index 053f5a019..e5431afe3 100644
--- a/apps/mobile/src/services/Message.js
+++ b/apps/mobile/src/services/Message.js
@@ -1,5 +1,9 @@
import {Actions} from '../provider/Actions';
-import {eOpenLoginDialog} from '../utils/Events';
+import {
+ eCloseProgressDialog,
+ eOpenLoginDialog,
+ eOpenProgressDialog,
+} from '../utils/Events';
import {eSendEvent} from './EventManager';
export function setLoginMessage(dispatch) {
@@ -8,12 +12,13 @@ export function setLoginMessage(dispatch) {
state: {
visible: true,
message: 'You are not logged in',
- actionText: 'Login to sync your notes',
+ actionText: 'Login to sync your data.',
onPress: () => {
eSendEvent(eOpenLoginDialog);
},
data: {},
icon: 'account-outline',
+ type:"normal"
},
});
}
@@ -23,16 +28,25 @@ export function setEmailVerifyMessage(dispatch) {
type: Actions.MESSAGE_BOARD_STATE,
state: {
visible: true,
- message: 'Email not verified',
- actionText: 'Please verify your email to sync notes',
+ message: 'Account not verified',
+ actionText: 'Please verify account to sync your data',
onPress: () => {
- // Handle this
- //eSendEvent(eOpen)
+ eSendEvent(eOpenProgressDialog, {
+ title: 'Account not verified',
+ paragraph:
+ 'We have sent you an account confirmation link. Please check your email to verify your account.',
+ action: () => {
+ eSendEvent(eCloseProgressDialog);
+ },
+ noProgress: true,
+ });
},
data: {},
- icon: 'account-outline',
+ icon: 'alert',
+ type:"error"
},
});
+
}
export function clearMessage(dispatch) {
diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.js
index 04a1ea603..8706ac578 100644
--- a/apps/mobile/src/views/Favorites/index.js
+++ b/apps/mobile/src/views/Favorites/index.js
@@ -12,6 +12,7 @@ export const Favorites = ({route, navigation}) => {
const [state, dispatch] = useTracked();
state.favorites.indexOf();
const favorites = state.favorites;
+ const {loading} = state;
let pageIsLoaded = false;
@@ -72,6 +73,7 @@ export const Favorites = ({route, navigation}) => {
refreshCallback={() => {
dispatch({type: Actions.FAVORITES});
}}
+ loading={loading}
placeholderData={{
heading: 'Your Favorites',
paragraph: 'You have not added any notes to favorites yet.',
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index f6749e12d..6471e7c85 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -19,7 +19,8 @@ import {eOnLoadNote, eScrollEvent, refreshNotesPage} from '../../utils/Events';
import {tabBarRef} from '../../utils/Refs';
export const Notes = ({route, navigation}) => {
- const [, dispatch] = useTracked();
+ const [state, dispatch] = useTracked();
+ const {loading} = state;
const [notes, setNotes] = useState([]);
let params = route.params ? route.params : null;
let pageIsLoaded = false;
@@ -72,7 +73,6 @@ export const Notes = ({route, navigation}) => {
});
}
let allNotes = [];
- console.log(params.type);
if (params.type === 'tag') {
allNotes = db.notes.tagged(params.tag.id);
} else if (params.type === 'color') {
@@ -197,6 +197,7 @@ export const Notes = ({route, navigation}) => {
? '#' + params.title
: params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
}}
+ loading={loading}
focused={() => navigation.isFocused()}
RenderItem={NoteItemWrapper}
placeholderText={`Add some notes to this" ${
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index fccc71fd3..7767d12d2 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -327,7 +327,7 @@ const CustomButton = ({
const SettingsUserSection = () => {
const [state] = useTracked();
- const {colors, user} = state;
+ const {colors, user,messageBoardState} = state;
const getTimeLeft = (t2) => {
let d1 = new Date(Date.now());
@@ -338,185 +338,180 @@ const SettingsUserSection = () => {
return diff < 0 ? 0 : diff;
};
- return user ? (
+ return (
<>
- <View
- style={{
- paddingHorizontal: 12,
+ {messageBoardState && <PressableButton
+ onPress={messageBoardState.onPress}
+ customStyle={{
+ paddingVertical: 12,
+ width: '100%',
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'flex-start',
+ paddingHorizontal: 6,
}}>
<View
style={{
- alignSelf: 'center',
- width: '100%',
- borderRadius: 5,
- paddingVertical: 12,
+ width: 40,
+ backgroundColor:messageBoardState.type === "error"? colors.red: colors.accent,
+ height: 40,
+ marginLeft: 10,
+ borderRadius: 100,
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}>
+ <Icon size={SIZE.lg} color="white" name={messageBoardState.icon} />
+ </View>
+
+ <View
+ style={{
+ marginLeft: 10,
}}>
+ <Paragraph color={colors.icon} size={SIZE.xs}>
+ {messageBoardState.message}
+ </Paragraph>
+ <Paragraph color={messageBoardState.type === "error"? colors.red: colors.accent}>{messageBoardState.actionText}</Paragraph>
+ </View>
+
+ <View
+ style={{
+ width: 40,
+ height: 40,
+ justifyContent: 'center',
+ alignItems: 'center',
+ position: 'absolute',
+ right: 6,
+ }}>
+ <Icon name="chevron-right" color={messageBoardState.type === "error"? colors.red: colors.accent} size={SIZE.lg} />
+ </View>
+ </PressableButton>}
+
+ {user ? (
+ <>
<View
style={{
- justifyContent: 'space-between',
- alignItems: 'center',
- flexDirection: 'row',
+ paddingHorizontal: 12,
}}>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'center',
- alignItems: 'center',
+ alignSelf: 'center',
+ width: '100%',
+ borderRadius: 5,
+ paddingVertical: 12,
}}>
<View
style={{
- borderWidth: 1,
- borderRadius: 100,
- borderColor: colors.accent,
- width: 20,
- height: 20,
+ justifyContent: 'space-between',
alignItems: 'center',
- justifyContent: 'center',
+ flexDirection: 'row',
}}>
- <Icon
- size={SIZE.md}
- color={colors.accent}
- name="account-outline"
- />
- </View>
+ <View
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ <View
+ style={{
+ borderWidth: 1,
+ borderRadius: 100,
+ borderColor: colors.accent,
+ width: 20,
+ height: 20,
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}>
+ <Icon
+ size={SIZE.md}
+ color={colors.accent}
+ name="account-outline"
+ />
+ </View>
- <Paragraph
- color={colors.heading}
- style={{
- marginLeft: 5,
- }}>
- {user?.email}
- </Paragraph>
- </View>
- <View
- style={{
- borderRadius: 5,
- padding: 5,
- paddingVertical: 2.5,
- }}>
- <Heading color={colors.accent} size={SIZE.sm}>
- {SUBSCRIPTION_STATUS_STRINGS[user.subscription.status]}
- </Heading>
- </View>
- </View>
- <Seperator />
- <View>
- {user.subscription.status === 1 ? (
- <View>
- <Paragraph
- size={SIZE.lg}
- color={
- getTimeLeft(parseInt(user.subscription.expiry)) > 5
- ? colors.pri
- : colors.errorText
- }>
- {getTimeLeft(parseInt(user.subscription.expiry)) +
- ' Days Remaining'}{' '}
- </Paragraph>
- <Paragraph color={colors.icon} size={SIZE.sm}>
- Your trail period started on{' '}
- {new Date(
- user.subscription.start * 1000,
- ).toLocaleDateString()}
- </Paragraph>
+ <Paragraph
+ color={colors.heading}
+ style={{
+ marginLeft: 5,
+ }}>
+ {user?.email}
+ </Paragraph>
+ </View>
+ <View
+ style={{
+ borderRadius: 5,
+ padding: 5,
+ paddingVertical: 2.5,
+ }}>
+ <Heading color={colors.accent} size={SIZE.sm}>
+ {SUBSCRIPTION_STATUS_STRINGS[user.subscription.status]}
+ </Heading>
+ </View>
</View>
- ) : null}
-
- <Seperator />
-
- <Button
- onPress={() => {
- eSendEvent(eOpenPremiumDialog);
- }}
- width="100%"
- fontSize={SIZE.md}
- title="Subscribe to Notesnook Pro"
- height={50}
- type="accent"
- />
- </View>
- </View>
- </View>
- {[
- {
- name: 'Save Data Recovery Key',
- func: async () => {
- eSendEvent(eOpenRecoveryKeyDialog);
- },
- desc:
- 'Recover your data using the recovery key if your password is lost.',
- },
- {
- name: 'Change Password',
- func: async () => {
- eSendEvent(eOpenLoginDialog, 3);
- },
- desc: 'Setup a new password for your account.',
- },
- ].map((item) => (
- <CustomButton
- key={item.name}
- title={item.name}
- onPress={item.func}
- tagline={item.desc}
- color={item.name === 'Logout' ? colors.errorText : colors.pri}
- />
- ))}
- </>
- ) : (
- <>
- <View
- style={{
- paddingHorizontal: 0,
- }}>
- <PressableButton
- onPress={() => {
- eSendEvent(eOpenLoginDialog);
- }}
- customStyle={{
- paddingVertical: 12,
- width: '100%',
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'flex-start',
- paddingHorizontal: 6,
- }}>
- <View
- style={{
- width: 40,
- backgroundColor: colors.accent,
- height: 40,
- marginLeft: 10,
- borderRadius: 100,
- alignItems: 'center',
- justifyContent: 'center',
- }}>
- <Icon size={SIZE.lg} color="white" name="account-outline" />
- </View>
+ <Seperator />
+ <View>
+ {user.subscription.status === 1 ? (
+ <View>
+ <Paragraph
+ size={SIZE.lg}
+ color={
+ getTimeLeft(parseInt(user.subscription.expiry)) > 5
+ ? colors.pri
+ : colors.errorText
+ }>
+ {getTimeLeft(parseInt(user.subscription.expiry)) +
+ ' Days Remaining'}{' '}
+ </Paragraph>
+ <Paragraph color={colors.icon} size={SIZE.sm}>
+ Your trail period started on{' '}
+ {new Date(
+ user.subscription.start * 1000,
+ ).toLocaleDateString()}
+ </Paragraph>
+ </View>
+ ) : null}
- <View
- style={{
- marginLeft: 10,
- }}>
- <Paragraph color={colors.icon} size={SIZE.xs}>
- You are not logged in
- </Paragraph>
- <Paragraph color={colors.accent}>Login to sync notes.</Paragraph>
- </View>
+ <Seperator />
- <View
- style={{
- width: 40,
- height: 40,
- justifyContent: 'center',
- alignItems: 'center',
- position: 'absolute',
- right: 6,
- }}>
- <Icon name="chevron-right" color={colors.accent} size={SIZE.lg} />
+ <Button
+ onPress={() => {
+ eSendEvent(eOpenPremiumDialog);
+ }}
+ width="100%"
+ fontSize={SIZE.md}
+ title="Subscribe to Notesnook Pro"
+ height={50}
+ type="accent"
+ />
+ </View>
+ </View>
</View>
- </PressableButton>
- </View>
+ {[
+ {
+ name: 'Save Data Recovery Key',
+ func: async () => {
+ eSendEvent(eOpenRecoveryKeyDialog);
+ },
+ desc:
+ 'Recover your data using the recovery key if your password is lost.',
+ },
+ {
+ name: 'Change Password',
+ func: async () => {
+ eSendEvent(eOpenLoginDialog, 3);
+ },
+ desc: 'Setup a new password for your account.',
+ },
+ ].map((item) => (
+ <CustomButton
+ key={item.name}
+ title={item.name}
+ onPress={item.func}
+ tagline={item.desc}
+ color={item.name === 'Logout' ? colors.errorText : colors.pri}
+ />
+ ))}
+ </>
+ ) : null}
</>
);
};