Skip to content

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

add ClearAll case to reducer

ammarahm-ed1ab75b0d9196
diff --git a/apps/mobile/src/provider/actions.js b/apps/mobile/src/provider/actions.js
index a97e4a71d..034f57b92 100644
--- a/apps/mobile/src/provider/actions.js
+++ b/apps/mobile/src/provider/actions.js
@@ -19,4 +19,5 @@ export const ACTIONS = {
SETTINGS: 'getSettings',
SELECT_ALL: 'selectAll',
ALL: 'all',
+ CLEAR_ALL: 'allClear'
};
diff --git a/apps/mobile/src/provider/reducer.js b/apps/mobile/src/provider/reducer.js
index 01ea81008..d6d87a9ab 100644
--- a/apps/mobile/src/provider/reducer.js
+++ b/apps/mobile/src/provider/reducer.js
@@ -1,6 +1,7 @@
import { history, db } from '../utils/utils';
import { ACTIONS } from './actions';
import { sideMenuRef } from '../utils/refs';
+import storage from '../utils/storage';
export const reducer = (state, action) => {
switch (action.type) {
@@ -22,6 +23,23 @@ export const reducer = (state, action) => {
colorNotes: db.colors.all,
};
}
+ case ACTIONS.CLEAR_ALL: {
+ storage.clear();
+ return {
+ ...state,
+ notes: [],
+ notebooks: [],
+ trash: [],
+ pinned: {
+ notes: [],
+ notebooks: []
+ },
+ tags: [],
+ favorites: [],
+ colorNotes: [],
+ user: null
+ }
+ }
case ACTIONS.NOTES:
let notes;
if (action.sort) {