MyCrypto/common/reducers/notifications.js

20 lines
562 B
JavaScript
Raw Normal View History

2017-06-21 16:31:59 -07:00
// @flow
import type { NotificationsAction, Notification } from 'actions/notifications';
type State = Notification[];
const initialState: State = [];
export function notifications(state: State = initialState, action: NotificationsAction): State {
switch (action.type) {
case 'SHOW_NOTIFICATION':
return state.concat(action.payload);
case 'CLOSE_NOTIFICATION':
state = [...state]
state.splice(state.indexOf(action.payload), 1);
return state
default:
return state;
}
}