You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

41 lines
889 B

import * as actions from '../actions';
7 years ago
export interface State {
enabled: boolean;
newTab: boolean;
background: boolean;
keys: string,
}
const defaultState: State = {
7 years ago
enabled: false,
newTab: false,
background: false,
keys: '',
7 years ago
};
export default function reducer(
state: State = defaultState,
action: actions.FollowAction,
): State {
7 years ago
switch (action.type) {
case actions.FOLLOW_CONTROLLER_ENABLE:
6 years ago
return { ...state,
7 years ago
enabled: true,
newTab: action.newTab,
background: action.background,
6 years ago
keys: '', };
case actions.FOLLOW_CONTROLLER_DISABLE:
6 years ago
return { ...state,
enabled: false, };
case actions.FOLLOW_CONTROLLER_KEY_PRESS:
6 years ago
return { ...state,
keys: state.keys + action.key, };
case actions.FOLLOW_CONTROLLER_BACKSPACE:
6 years ago
return { ...state,
keys: state.keys.slice(0, -1), };
7 years ago
default:
return state;
}
}