Skip to content

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

add logout function

ammarahm-ed1d7cff15a0e6
diff --git a/apps/mobile/App.js b/apps/mobile/App.js
index a66e4aa6f..641e1c9a6 100644
--- a/apps/mobile/App.js
+++ b/apps/mobile/App.js
@@ -46,7 +46,7 @@ const App = () => {
db.init().then(async () => {
let user = await db.user.get();
dispatch({type: ACTIONS.USER, user: user});
- dispatch({type: ACTIONS.ALL});
+
setInit(true);
});
});
diff --git a/apps/mobile/src/provider/reducer.js b/apps/mobile/src/provider/reducer.js
index ea1a85b56..a52ae9331 100644
--- a/apps/mobile/src/provider/reducer.js
+++ b/apps/mobile/src/provider/reducer.js
@@ -7,10 +7,11 @@ export const reducer = (state, action) => {
case ACTIONS.ALL: {
let notes = db.notes.pinned;
let notebooks = db.notebooks.pinned;
+
return {
...state,
notes: db.notes.group(),
- user: action.user,
+
notebooks: db.notebooks.all,
trash: db.trash.all,
pinned: {
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index 9952a8eec..4da3eb40f 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -27,7 +27,7 @@ import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {eOpenLoginDialog} from '../../services/events';
import NavigationService from '../../services/NavigationService';
-import {hexToRGBA, w, DDS, setSetting} from '../../utils/utils';
+import {hexToRGBA, w, DDS, setSetting, db, ToastEvent} from '../../utils/utils';
export const Settings = ({navigation}) => {
const [state, dispatch] = useTracked();
@@ -143,24 +143,35 @@ export const Settings = ({navigation}) => {
{[
{
name: 'Backup my notes',
+ func: () => {},
},
{
name: 'My vault',
+ func: () => {},
},
{
name: 'Subscription status',
+ func: () => {},
},
{
name: 'Change password',
+ func: () => {},
},
{
name: 'Logout',
+ func: async () => {
+ await db.user.logout();
+ dispatch({type: ACTIONS.USER, user: null});
+ dispatch({type: ACTIONS.ALL});
+ ToastEvent.show('Logged out, syncing disabled', 'success');
+ },
},
].map(item => (
<TouchableOpacity
key={item.name}
activeOpacity={opacity}
+ onPress={item.func}
style={{
width: '100%',