diff options
author | kibigo! <marrus-sh@users.noreply.github.com> | 2017-11-17 19:16:35 -0800 |
---|---|---|
committer | kibigo! <marrus-sh@users.noreply.github.com> | 2017-11-17 19:29:16 -0800 |
commit | e19fc6a9f81e3756e0198006d2eafbc2f3acadb5 (patch) | |
tree | 4e91fa8891da88ce1ea25a2b7edcffbe62a7a4d1 /app/javascript/mastodon/reducers/alerts.js | |
parent | 45c44989c8fb6e24badd18bb83ac5f68de0aceaf (diff) |
Restore vanilla components
Diffstat (limited to 'app/javascript/mastodon/reducers/alerts.js')
-rw-r--r-- | app/javascript/mastodon/reducers/alerts.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/javascript/mastodon/reducers/alerts.js b/app/javascript/mastodon/reducers/alerts.js new file mode 100644 index 000000000..089d920c3 --- /dev/null +++ b/app/javascript/mastodon/reducers/alerts.js @@ -0,0 +1,25 @@ +import { + ALERT_SHOW, + ALERT_DISMISS, + ALERT_CLEAR, +} from '../actions/alerts'; +import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; + +const initialState = ImmutableList([]); + +export default function alerts(state = initialState, action) { + switch(action.type) { + case ALERT_SHOW: + return state.push(ImmutableMap({ + key: state.size > 0 ? state.last().get('key') + 1 : 0, + title: action.title, + message: action.message, + })); + case ALERT_DISMISS: + return state.filterNot(item => item.get('key') === action.alert.key); + case ALERT_CLEAR: + return state.clear(); + default: + return state; + } +}; |