2018-04-05 19:13:32 +00:00
|
|
|
import createReducer from 'utils/createReducer';
|
|
|
|
import { LOCATION_CHANGED } from 'utils/router';
|
2017-05-26 06:20:00 +00:00
|
|
|
import * as actions from './actions';
|
|
|
|
|
2018-04-25 03:36:27 +00:00
|
|
|
const initialState = {
|
2017-05-26 06:20:00 +00:00
|
|
|
showTabList: false,
|
|
|
|
showUserList: false
|
2018-04-25 03:36:27 +00:00
|
|
|
};
|
2017-05-26 06:20:00 +00:00
|
|
|
|
|
|
|
export const getShowTabList = state => state.ui.showTabList;
|
|
|
|
export const getShowUserList = state => state.ui.showUserList;
|
|
|
|
|
|
|
|
function setMenuHidden(state) {
|
2018-04-25 03:36:27 +00:00
|
|
|
state.showTabList = false;
|
2017-05-26 06:20:00 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 03:36:27 +00:00
|
|
|
export default createReducer(initialState, {
|
2017-05-26 06:20:00 +00:00
|
|
|
[actions.TOGGLE_MENU](state) {
|
2018-04-25 03:36:27 +00:00
|
|
|
state.showTabList = !state.showTabList;
|
2017-05-26 06:20:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
[actions.HIDE_MENU]: setMenuHidden,
|
|
|
|
[LOCATION_CHANGED]: setMenuHidden,
|
|
|
|
|
|
|
|
[actions.TOGGLE_USERLIST](state) {
|
2018-04-25 03:36:27 +00:00
|
|
|
state.showUserList = !state.showUserList;
|
2017-05-26 06:20:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export function hideMenu() {
|
|
|
|
return {
|
|
|
|
type: actions.HIDE_MENU
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toggleMenu() {
|
|
|
|
return {
|
|
|
|
type: actions.TOGGLE_MENU
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toggleUserList() {
|
|
|
|
return {
|
|
|
|
type: actions.TOGGLE_USERLIST
|
|
|
|
};
|
|
|
|
}
|