diff options
Diffstat (limited to 'src/content/reducers')
-rw-r--r-- | src/content/reducers/addon.ts | 13 | ||||
-rw-r--r-- | src/content/reducers/find.ts | 14 | ||||
-rw-r--r-- | src/content/reducers/follow-controller.ts | 16 | ||||
-rw-r--r-- | src/content/reducers/index.ts | 22 | ||||
-rw-r--r-- | src/content/reducers/input.ts | 13 | ||||
-rw-r--r-- | src/content/reducers/mark.ts | 20 | ||||
-rw-r--r-- | src/content/reducers/setting.ts | 11 |
7 files changed, 86 insertions, 23 deletions
diff --git a/src/content/reducers/addon.ts b/src/content/reducers/addon.ts index 0def55a..2131228 100644 --- a/src/content/reducers/addon.ts +++ b/src/content/reducers/addon.ts @@ -1,10 +1,17 @@ -import actions from 'content/actions'; +import * as actions from '../actions'; -const defaultState = { +export interface State { + enabled: boolean; +} + +const defaultState: State = { enabled: true, }; -export default function reducer(state = defaultState, action = {}) { +export default function reducer( + state: State = defaultState, + action: actions.AddonAction, +): State { switch (action.type) { case actions.ADDON_SET_ENABLED: return { ...state, diff --git a/src/content/reducers/find.ts b/src/content/reducers/find.ts index 4560e2c..8c3e637 100644 --- a/src/content/reducers/find.ts +++ b/src/content/reducers/find.ts @@ -1,11 +1,19 @@ -import actions from 'content/actions'; +import * as actions from '../actions'; -const defaultState = { +export interface State { + keyword: string | null; + found: boolean; +} + +const defaultState: State = { keyword: null, found: false, }; -export default function reducer(state = defaultState, action = {}) { +export default function reducer( + state: State = defaultState, + action: actions.FindAction, +): State { switch (action.type) { case actions.FIND_SET_KEYWORD: return { ...state, diff --git a/src/content/reducers/follow-controller.ts b/src/content/reducers/follow-controller.ts index 5869c47..6965704 100644 --- a/src/content/reducers/follow-controller.ts +++ b/src/content/reducers/follow-controller.ts @@ -1,13 +1,23 @@ -import actions from 'content/actions'; +import * as actions from '../actions'; -const defaultState = { +export interface State { + enabled: boolean; + newTab: boolean; + background: boolean; + keys: string, +} + +const defaultState: State = { enabled: false, newTab: false, background: false, keys: '', }; -export default function reducer(state = defaultState, action = {}) { +export default function reducer( + state: State = defaultState, + action: actions.FollowAction, +): State { switch (action.type) { case actions.FOLLOW_CONTROLLER_ENABLE: return { ...state, diff --git a/src/content/reducers/index.ts b/src/content/reducers/index.ts index bf612a3..fb5eb84 100644 --- a/src/content/reducers/index.ts +++ b/src/content/reducers/index.ts @@ -1,10 +1,20 @@ import { combineReducers } from 'redux'; -import addon from './addon'; -import find from './find'; -import setting from './setting'; -import input from './input'; -import followController from './follow-controller'; -import mark from './mark'; +import addon, { State as AddonState } from './addon'; +import find, { State as FindState } from './find'; +import setting, { State as SettingState } from './setting'; +import input, { State as InputState } from './input'; +import followController, { State as FollowControllerState } + from './follow-controller'; +import mark, { State as MarkState } from './mark'; + +export interface State { + addon: AddonState; + find: FindState; + setting: SettingState; + input: InputState; + followController: FollowControllerState; + mark: MarkState; +} export default combineReducers({ addon, find, setting, input, followController, mark, diff --git a/src/content/reducers/input.ts b/src/content/reducers/input.ts index 23e7dd2..6257e49 100644 --- a/src/content/reducers/input.ts +++ b/src/content/reducers/input.ts @@ -1,10 +1,17 @@ -import actions from 'content/actions'; +import * as actions from '../actions'; -const defaultState = { +export interface State { + keys: string[]; +} + +const defaultState: State = { keys: [] }; -export default function reducer(state = defaultState, action = {}) { +export default function reducer( + state: State = defaultState, + action: actions.InputAction, +): State { switch (action.type) { case actions.INPUT_KEY_PRESS: return { ...state, diff --git a/src/content/reducers/mark.ts b/src/content/reducers/mark.ts index 2c96cc5..e78b7b9 100644 --- a/src/content/reducers/mark.ts +++ b/src/content/reducers/mark.ts @@ -1,12 +1,26 @@ -import actions from 'content/actions'; +import * as actions from '../actions'; -const defaultState = { +interface Mark { + x: number; + y: number; +} + +export interface State { + setMode: boolean; + jumpMode: boolean; + marks: { [key: string]: Mark }; +} + +const defaultState: State = { setMode: false, jumpMode: false, marks: {}, }; -export default function reducer(state = defaultState, action = {}) { +export default function reducer( + state: State = defaultState, + action: actions.MarkAction, +): State { switch (action.type) { case actions.MARK_START_SET: return { ...state, setMode: true }; diff --git a/src/content/reducers/setting.ts b/src/content/reducers/setting.ts index a49db6d..fa8e8ee 100644 --- a/src/content/reducers/setting.ts +++ b/src/content/reducers/setting.ts @@ -1,11 +1,18 @@ -import actions from 'content/actions'; +import * as actions from '../actions'; + +export interface State { + keymaps: any[]; +} const defaultState = { // keymaps is and arrays of key-binding pairs, which is entries of Map keymaps: [], }; -export default function reducer(state = defaultState, action = {}) { +export default function reducer( + state: State = defaultState, + action: actions.SettingAction, +): State { switch (action.type) { case actions.SETTING_SET: return { ...action.value }; |