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.
26 lines
659 B
26 lines
659 B
8 years ago
|
import {
|
||
|
ALERT_SHOW,
|
||
|
ALERT_DISMISS,
|
||
8 years ago
|
ALERT_CLEAR,
|
||
7 years ago
|
} from 'flavours/glitch/actions/alerts';
|
||
8 years ago
|
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||
8 years ago
|
|
||
8 years ago
|
const initialState = ImmutableList([]);
|
||
8 years ago
|
|
||
|
export default function alerts(state = initialState, action) {
|
||
|
switch(action.type) {
|
||
8 years ago
|
case ALERT_SHOW:
|
||
8 years ago
|
return state.push(ImmutableMap({
|
||
8 years ago
|
key: state.size > 0 ? state.last().get('key') + 1 : 0,
|
||
|
title: action.title,
|
||
8 years ago
|
message: action.message,
|
||
8 years ago
|
}));
|
||
|
case ALERT_DISMISS:
|
||
|
return state.filterNot(item => item.get('key') === action.alert.key);
|
||
|
case ALERT_CLEAR:
|
||
|
return state.clear();
|
||
|
default:
|
||
|
return state;
|
||
8 years ago
|
}
|
||
|
};
|