Skip to content

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

update

ammarahm-edc12ceb89fbf2
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index a4563b1cc..13bc5ac77 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -540,7 +540,7 @@ export const Menu = ({
))}
</View>
- {!user && !user.username ? (
+ {user && user.username ? (
<View
style={{
width: '100%',
diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.js
index 2811ce417..07bda186e 100644
--- a/apps/mobile/src/components/NotesList/index.js
+++ b/apps/mobile/src/components/NotesList/index.js
@@ -199,8 +199,7 @@ export const NotesList = ({isGrouped = false}) => {
await db.sync();
dispatch({type: ACTIONS.NOTES});
dispatch({type: ACTIONS.PINNED});
- dispatch({type: ACTIONS.FAVORITES});
-
+ dispatch({type: ACTIONS.USER});
setRefreshing(false);
ToastEvent.show('Sync Complete', 'success');
} catch (e) {
diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.js
index d0a4f184a..708466c34 100644
--- a/apps/mobile/src/views/Favorites/index.js
+++ b/apps/mobile/src/views/Favorites/index.js
@@ -10,6 +10,7 @@ import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {eScrollEvent} from '../../services/events';
+import {ToastEvent} from '../../utils/utils';
export const Favorites = ({navigation}) => {
const [state, dispatch] = useTracked();
@@ -40,11 +41,19 @@ export const Favorites = ({navigation}) => {
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
- onRefresh={() => {
+ onRefresh={async () => {
setRefreshing(true);
- setTimeout(() => {
+ try {
+ await db.sync();
+
+ dispatch({type: ACTIONS.FAVORITES});
+ dispatch({type: ACTIONS.USER});
+ setRefreshing(false);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
setRefreshing(false);
- }, 1000);
+ ToastEvent.show('Sync failed, network error', 'error');
+ }
}}
refreshing={refreshing}
/>
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index b4ea7bc00..8d7573101 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -20,7 +20,7 @@ import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {eScrollEvent} from '../../services/events';
import {slideLeft, slideRight} from '../../utils/animations';
-import {w} from '../../utils/utils';
+import {w, ToastEvent} from '../../utils/utils';
export const Folders = ({navigation}) => {
const [state, dispatch] = useTracked();
@@ -95,11 +95,19 @@ export const Folders = ({navigation}) => {
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
- onRefresh={() => {
+ onRefresh={async () => {
setRefreshing(true);
- setTimeout(() => {
+ try {
+ await db.sync();
+ dispatch({type: ACTIONS.NOTEBOOKS});
+ dispatch({type: ACTIONS.PINNED});
+ dispatch({type: ACTIONS.USER});
setRefreshing(false);
- }, 1000);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
+ setRefreshing(false);
+ ToastEvent.show('Sync failed, network error', 'error');
+ }
}}
refreshing={refreshing}
/>
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index 9c301450f..1bc50efe3 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -18,6 +18,7 @@ import {
eOnNewTopicAdded,
eScrollEvent,
} from '../../services/events';
+import {ToastEvent} from '../../utils/utils';
export const Notebook = ({navigation}) => {
const [state, dispatch] = useTracked();
@@ -157,11 +158,19 @@ export const Notebook = ({navigation}) => {
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
- onRefresh={() => {
+ onRefresh={async () => {
setRefreshing(true);
- setTimeout(() => {
+ try {
+ await db.sync();
+
+ onLoad();
+ dispatch({type: ACTIONS.USER});
+ setRefreshing(false);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
setRefreshing(false);
- }, 1000);
+ ToastEvent.show('Sync failed, network error', 'error');
+ }
}}
refreshing={refreshing}
/>
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 908727573..f52233518 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -7,6 +7,7 @@ import SelectionWrapper from '../../components/SelectionWrapper';
import {useTracked} from '../../provider';
import {SIZE, WEIGHT} from '../../common/common';
import {ACTIONS} from '../../provider/actions';
+import {ToastEvent} from '../../utils/utils';
export const Notes = ({navigation}) => {
const [state, dispatch] = useTracked();
@@ -24,14 +25,14 @@ export const Notes = ({navigation}) => {
}
}, []);
- useEffect(() => {
+ const init = () => {
eSendEvent(eScrollEvent, 0);
if (params.type === 'tag') {
let notesInTag = db.notes.tagged(params.tag.title);
setNotes([...notesInTag]);
} else if (params.type == 'color') {
let notesInColors = db.notes.colored(params.color.id);
- console.log(notesInColors);
+
setNotes([...notesInColors]);
//setNotes(...);
} else {
@@ -42,6 +43,10 @@ export const Notes = ({navigation}) => {
setNotes(allNotes);
}
}
+ };
+
+ useEffect(() => {
+ init();
}, [allNotes, colorNotes]);
const _renderItem = ({item, index}) => (
@@ -135,11 +140,19 @@ export const Notes = ({navigation}) => {
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
- onRefresh={() => {
+ onRefresh={async () => {
setRefreshing(true);
- setTimeout(() => {
+ try {
+ await db.sync();
+
+ init();
+ dispatch({type: ACTIONS.USER});
+ setRefreshing(false);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
setRefreshing(false);
- }, 1000);
+ ToastEvent.show('Sync failed, network error', 'error');
+ }
}}
refreshing={refreshing}
/>
diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.js
index fef4ee157..e1032eb70 100644
--- a/apps/mobile/src/views/Tags/index.js
+++ b/apps/mobile/src/views/Tags/index.js
@@ -14,6 +14,7 @@ import {TagsPlaceHolder} from '../../components/ListPlaceholders';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import NavigationService from '../../services/NavigationService';
+import {ToastEvent} from '../../utils/utils';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -63,11 +64,19 @@ export const Tags = ({navigation}) => {
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
- onRefresh={() => {
+ onRefresh={async () => {
setRefreshing(true);
- setTimeout(() => {
+ try {
+ await db.sync();
+
+ dispatch({type: ACTIONS.TAGS});
+ dispatch({type: ACTIONS.USER});
+ setRefreshing(false);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
setRefreshing(false);
- }, 1000);
+ ToastEvent.show('Sync failed, network error', 'error');
+ }
}}
refreshing={refreshing}
/>
diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js
index 30e0ae28f..d16ccc883 100644
--- a/apps/mobile/src/views/Trash/index.js
+++ b/apps/mobile/src/views/Trash/index.js
@@ -11,7 +11,7 @@ import {NotebookItem} from '../../components/NotebookItem';
import NoteItem from '../../components/NoteItem';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
-import {w} from '../../utils/utils';
+import {w, ToastEvent} from '../../utils/utils';
import SelectionWrapper from '../../components/SelectionWrapper';
export const Trash = ({navigation}) => {
@@ -111,11 +111,19 @@ export const Trash = ({navigation}) => {
tintColor={colors.accent}
colors={[colors.accent]}
progressViewOffset={165}
- onRefresh={() => {
+ onRefresh={async () => {
setRefreshing(true);
- setTimeout(() => {
+ try {
+ await db.sync();
+
+ dispatch({type: ACTIONS.TRASH});
+ dispatch({type: ACTIONS.USER});
+ setRefreshing(false);
+ ToastEvent.show('Sync Complete', 'success');
+ } catch (e) {
setRefreshing(false);
- }, 1000);
+ ToastEvent.show('Sync failed, network error', 'error');
+ }
}}
refreshing={refreshing}
/>