diff options
Diffstat (limited to 'src/background/reducers')
-rw-r--r-- | src/background/reducers/find.js | 16 | ||||
-rw-r--r-- | src/background/reducers/index.js | 6 | ||||
-rw-r--r-- | src/background/reducers/tab.js | 19 |
3 files changed, 41 insertions, 0 deletions
diff --git a/src/background/reducers/find.js b/src/background/reducers/find.js new file mode 100644 index 0000000..4ded801 --- /dev/null +++ b/src/background/reducers/find.js @@ -0,0 +1,16 @@ +import actions from 'content/actions'; + +const defaultState = { + keyword: null, +}; + +export default function reducer(state = defaultState, action = {}) { + switch (action.type) { + case actions.FIND_SET_KEYWORD: + return Object.assign({}, state, { + keyword: action.keyword, + }); + default: + return state; + } +} diff --git a/src/background/reducers/index.js b/src/background/reducers/index.js index dab0c62..5729f0a 100644 --- a/src/background/reducers/index.js +++ b/src/background/reducers/index.js @@ -1,12 +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), }); } diff --git a/src/background/reducers/tab.js b/src/background/reducers/tab.js new file mode 100644 index 0000000..e0cdf32 --- /dev/null +++ b/src/background/reducers/tab.js @@ -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; + } +} + |