Previous selected tab as redux

This commit is contained in:
Shin'ya Ueoka 2018-05-06 16:11:40 +09:00
parent 98bc2326ee
commit 2c366ac3b1
8 changed files with 64 additions and 15 deletions

View file

@ -1,15 +1,18 @@
import settingReducer from './setting';
import findReducer from './find';
import tabReducer from './tab';
// Make setting reducer instead of re-use
const defaultState = {
setting: settingReducer(undefined, {}),
find: findReducer(undefined, {}),
tab: tabReducer(undefined, {}),
};
export default function reducer(state = defaultState, action = {}) {
return Object.assign({}, state, {
setting: settingReducer(state.setting, action),
find: findReducer(state.find, action),
tab: tabReducer(state.tab, action),
});
}

View file

@ -0,0 +1,19 @@
import actions from 'background/actions';
const defaultState = {
previousSelected: -1,
currentSelected: -1,
};
export default function reducer(state = defaultState, action = {}) {
switch (action.type) {
case actions.TAB_SELECTED:
return {
previousSelected: state.currentSelected,
currentSelected: action.tabId,
};
default:
return state;
}
}