2022-02-02 18:27:10 +00:00
|
|
|
import { TActionApp } from '../actions/app';
|
|
|
|
import { RootEnum } from '../definitions';
|
2020-05-08 17:04:37 +00:00
|
|
|
import { APP, APP_STATE } from '../actions/actionsTypes';
|
2017-09-21 17:08:00 +00:00
|
|
|
|
2022-02-02 18:27:10 +00:00
|
|
|
export interface IApp {
|
|
|
|
root?: RootEnum;
|
|
|
|
isMasterDetail: boolean;
|
|
|
|
text?: string;
|
|
|
|
ready: boolean;
|
|
|
|
foreground: boolean;
|
|
|
|
background: boolean;
|
2023-02-14 13:47:56 +00:00
|
|
|
notificationPresenceCap: boolean;
|
2022-02-02 18:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const initialState: IApp = {
|
|
|
|
root: undefined,
|
2020-06-15 14:00:46 +00:00
|
|
|
isMasterDetail: false,
|
2022-02-02 18:27:10 +00:00
|
|
|
text: undefined,
|
2017-12-01 15:06:56 +00:00
|
|
|
ready: false,
|
2020-05-08 17:04:37 +00:00
|
|
|
foreground: true,
|
2023-02-14 13:47:56 +00:00
|
|
|
background: false,
|
|
|
|
notificationPresenceCap: false
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
|
|
|
|
2022-02-02 18:27:10 +00:00
|
|
|
export default function app(state = initialState, action: TActionApp): IApp {
|
2017-09-21 17:08:00 +00:00
|
|
|
switch (action.type) {
|
2020-05-08 17:04:37 +00:00
|
|
|
case APP_STATE.FOREGROUND:
|
2017-12-01 15:06:56 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
foreground: true,
|
|
|
|
background: false
|
|
|
|
};
|
2020-05-08 17:04:37 +00:00
|
|
|
case APP_STATE.BACKGROUND:
|
2017-12-01 15:06:56 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
foreground: false,
|
|
|
|
background: true
|
|
|
|
};
|
2018-07-10 13:40:32 +00:00
|
|
|
case APP.START:
|
|
|
|
return {
|
|
|
|
...state,
|
2020-06-15 14:00:46 +00:00
|
|
|
root: action.root,
|
|
|
|
text: action.text
|
2018-07-10 13:40:32 +00:00
|
|
|
};
|
2017-09-21 17:08:00 +00:00
|
|
|
case APP.INIT:
|
|
|
|
return {
|
|
|
|
...state,
|
2018-12-05 20:52:08 +00:00
|
|
|
ready: false
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
|
|
|
case APP.READY:
|
|
|
|
return {
|
|
|
|
...state,
|
2018-12-05 20:52:08 +00:00
|
|
|
ready: true
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
2020-06-15 14:00:46 +00:00
|
|
|
case APP.SET_MASTER_DETAIL:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isMasterDetail: action.isMasterDetail
|
|
|
|
};
|
2023-02-14 13:47:56 +00:00
|
|
|
case APP.SET_NOTIFICATION_PRESENCE_CAP:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
notificationPresenceCap: action.show
|
|
|
|
};
|
2017-09-21 17:08:00 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|