2016-08-31 15:15:12 +01:00
|
|
|
import { TIMELINE_SET, TIMELINE_UPDATE } from '../actions/timelines';
|
|
|
|
import Immutable from 'immutable';
|
2016-08-24 16:56:44 +01:00
|
|
|
|
|
|
|
const initialState = Immutable.Map();
|
|
|
|
|
2016-08-31 15:15:12 +01:00
|
|
|
export default function timelines(state = initialState, action) {
|
2016-08-24 16:56:44 +01:00
|
|
|
switch(action.type) {
|
2016-08-31 15:15:12 +01:00
|
|
|
case TIMELINE_SET:
|
2016-08-24 16:56:44 +01:00
|
|
|
return state.set(action.timeline, Immutable.fromJS(action.statuses));
|
2016-08-31 15:15:12 +01:00
|
|
|
case TIMELINE_UPDATE:
|
2016-08-24 16:56:44 +01:00
|
|
|
return state.update(action.timeline, function (list) {
|
2016-08-24 22:33:46 +01:00
|
|
|
return list.unshift(Immutable.fromJS(action.status));
|
2016-08-24 16:56:44 +01:00
|
|
|
});
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|