The code powering m.abunchtell.com https://m.abunchtell.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

26 行
633 B

  1. import {
  2. ALERT_SHOW,
  3. ALERT_DISMISS,
  4. ALERT_CLEAR
  5. } from '../actions/alerts';
  6. import Immutable from 'immutable';
  7. const initialState = Immutable.List([]);
  8. export default function alerts(state = initialState, action) {
  9. switch(action.type) {
  10. case ALERT_SHOW:
  11. return state.push(Immutable.Map({
  12. key: state.size > 0 ? state.last().get('key') + 1 : 0,
  13. title: action.title,
  14. message: action.message
  15. }));
  16. case ALERT_DISMISS:
  17. return state.filterNot(item => item.get('key') === action.alert.key);
  18. case ALERT_CLEAR:
  19. return state.clear();
  20. default:
  21. return state;
  22. }
  23. };