dispatch/client/js/state/ui.js

47 lines
936 B
JavaScript
Raw Normal View History

import createReducer from 'utils/createReducer';
import { LOCATION_CHANGED } from 'utils/router';
import * as actions from './actions';
2018-04-25 03:36:27 +00:00
const initialState = {
showTabList: false,
showUserList: false
2018-04-25 03:36:27 +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;
}
2018-04-25 03:36:27 +00:00
export default createReducer(initialState, {
[actions.TOGGLE_MENU](state) {
2018-04-25 03:36:27 +00:00
state.showTabList = !state.showTabList;
},
[actions.HIDE_MENU]: setMenuHidden,
[LOCATION_CHANGED]: setMenuHidden,
[actions.TOGGLE_USERLIST](state) {
2018-04-25 03:36:27 +00:00
state.showUserList = !state.showUserList;
}
});
export function hideMenu() {
return {
type: actions.HIDE_MENU
};
}
export function toggleMenu() {
return {
type: actions.TOGGLE_MENU
};
}
export function toggleUserList() {
return {
type: actions.TOGGLE_USERLIST
};
}