Skip to content

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

add app Loading reducer

ammarahm-ed9f8d5a69ba3c
diff --git a/apps/mobile/src/provider/Actions.js b/apps/mobile/src/provider/Actions.js
index 312e96003..2e80337fc 100644
--- a/apps/mobile/src/provider/Actions.js
+++ b/apps/mobile/src/provider/Actions.js
@@ -27,5 +27,6 @@ export const Actions = {
CONTAINER_BOTTOM_BUTTON:'containerBottomButton',
HEADER_VERTICAL_MENU:'verticalMenu',
HEADER_TEXT_STATE:'headerTextState',
- MESSAGE_BOARD_STATE:'messageBoardState'
+ MESSAGE_BOARD_STATE:'messageBoardState',
+ LOADING:"loading"
};
diff --git a/apps/mobile/src/provider/Reducer.js b/apps/mobile/src/provider/Reducer.js
index 308430c82..6a491b36c 100644
--- a/apps/mobile/src/provider/Reducer.js
+++ b/apps/mobile/src/provider/Reducer.js
@@ -1,18 +1,16 @@
-import { eSendEvent } from '../services/EventManager';
-import { eCloseSideMenu, eOpenSideMenu } from '../utils/Events';
+import {eSendEvent} from '../services/EventManager';
+import {eCloseSideMenu, eOpenSideMenu} from '../utils/Events';
import storage from '../utils/storage';
import {history, SORT, sortSettings} from '../utils/index';
-import { Actions } from './Actions';
-import {db} from "../utils/DB";
+import {Actions} from './Actions';
+import {db} from '../utils/DB';
export const reducer = (state, action) => {
switch (action.type) {
case Actions.ALL: {
-
-
return {
...state,
- notes: db.notes.group(SORT[sortSettings.sort]),
+ notes: db.notes.group(SORT[sortSettings.sort]),
notebooks: db.notebooks.all,
trash: db.trash.all,
tags: db.tags.all,
@@ -26,6 +24,12 @@ export const reducer = (state, action) => {
syncing: action.syncing,
};
}
+ case Actions.LOADING: {
+ return {
+ ...state,
+ syncing: action.loading,
+ };
+ }
case Actions.CLEAR_ALL: {
storage.clear();
return {
@@ -44,11 +48,9 @@ export const reducer = (state, action) => {
};
}
case Actions.NOTES:
-
return {
...state,
notes: db.notes.group(SORT[sortSettings.sort]),
- loading: false,
};
case Actions.THEME: {
return {
@@ -179,29 +181,27 @@ export const reducer = (state, action) => {
};
}
case Actions.SEARCH_RESULTS: {
-
return {
...state,
- searchResults:action.results,
+ searchResults: action.results,
};
}
case Actions.HEADER_STATE: {
-
- return {
- ...state,
- headerMenuState:action.state
- };
+ return {
+ ...state,
+ headerMenuState: action.state,
+ };
}
case Actions.SEARCH_STATE: {
let stat = {
- ...state.searchState,
- ...action.state,
- };
+ ...state.searchState,
+ ...action.state,
+ };
return {
- ...state,
- searchState: stat,
- };
+ ...state,
+ searchState: stat,
+ };
}
case Actions.CONTAINER_STATE: {
return {
@@ -210,14 +210,14 @@ export const reducer = (state, action) => {
};
}
case Actions.HEADER_TEXT_STATE: {
- let stat ={
- ...state.headerTextState,
- ...action.state,
- };
+ let stat = {
+ ...state.headerTextState,
+ ...action.state,
+ };
return {
- ...state,
- headerTextState: stat,
- };
+ ...state,
+ headerTextState: stat,
+ };
}
case Actions.HEADER_VERTICAL_MENU: {
return {
@@ -227,19 +227,19 @@ export const reducer = (state, action) => {
}
case Actions.CONTAINER_BOTTOM_BUTTON: {
let containerBottomButton = {
- ...state.containerBottomButton,
- ...action.state,
- };
+ ...state.containerBottomButton,
+ ...action.state,
+ };
return {
- ...state,
- containerBottomButton: containerBottomButton,
- };
+ ...state,
+ containerBottomButton: containerBottomButton,
+ };
}
case Actions.MESSAGE_BOARD_STATE: {
return {
...state,
- messageBoardState:action.state
- }
+ messageBoardState: action.state,
+ };
}
default:
throw new Error('unknown action type');