mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-10 11:05:47 +00:00
1aad9d1c21
* Convert Swap to consistent style * Generate wallet reducer cleanup. * Confirm empty action in swap reducer * Union types. Fix gen wallet collision * Fix not using all actions in reducer. Added reducer state for is fetching from bity. Added todo to make that a loader. * Readme instructions. * Remove common action constants. * Bring all actions and reducers inline with readme instructions. * Readme fixes * address comments
36 lines
837 B
JavaScript
36 lines
837 B
JavaScript
// @flow
|
|
import type {
|
|
NotificationsAction,
|
|
Notification,
|
|
ShowNotificationAction,
|
|
CloseNotificationAction
|
|
} from 'actions/notifications';
|
|
|
|
export type State = Notification[];
|
|
|
|
export const INITIAL_STATE: State = [];
|
|
|
|
function showNotification(state: State, action: ShowNotificationAction): State {
|
|
return state.concat(action.payload);
|
|
}
|
|
|
|
function closeNotification(state, action: CloseNotificationAction): State {
|
|
state = [...state];
|
|
state.splice(state.indexOf(action.payload), 1);
|
|
return state;
|
|
}
|
|
|
|
export function notifications(
|
|
state: State = INITIAL_STATE,
|
|
action: NotificationsAction
|
|
): State {
|
|
switch (action.type) {
|
|
case 'SHOW_NOTIFICATION':
|
|
return showNotification(state, action);
|
|
case 'CLOSE_NOTIFICATION':
|
|
return closeNotification(state, action);
|
|
default:
|
|
return state;
|
|
}
|
|
}
|