Rocket.Chat.ReactNative/app/reducers/app.js

47 lines
781 B
JavaScript

import { APP, APP_STATE } from '../actions/actionsTypes';
const initialState = {
root: null,
text: '',
previousServer: '',
ready: false,
foreground: true,
background: false
};
export default function app(state = initialState, action) {
switch (action.type) {
case APP_STATE.FOREGROUND:
return {
...state,
foreground: true,
background: false
};
case APP_STATE.BACKGROUND:
return {
...state,
foreground: false,
background: true
};
case APP.START:
return {
...state,
root: action.root,
text: action.text,
previousServer: action.previousServer
};
case APP.INIT:
return {
...state,
ready: false
};
case APP.READY:
return {
...state,
ready: true
};
default:
return state;
}
}