2020-03-27 22:57:03 +00:00
|
|
|
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable'
|
|
|
|
import {
|
2020-11-25 21:22:37 +00:00
|
|
|
STATUS_REVISIONS_LOAD_REQUEST,
|
2020-03-27 22:57:03 +00:00
|
|
|
STATUS_REVISIONS_LOAD_SUCCESS,
|
|
|
|
STATUS_REVISIONS_LOAD_FAIL
|
|
|
|
} from '../actions/status_revisions'
|
|
|
|
|
|
|
|
const initialState = ImmutableMap({
|
|
|
|
loading: false,
|
|
|
|
error: null,
|
|
|
|
revisions: ImmutableList(),
|
|
|
|
})
|
|
|
|
|
|
|
|
export default function statusRevisions(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2020-11-25 21:22:37 +00:00
|
|
|
case STATUS_REVISIONS_LOAD_REQUEST:
|
|
|
|
return state.withMutations((mutable) => {
|
|
|
|
mutable.set('loading', true)
|
|
|
|
})
|
2020-03-27 22:57:03 +00:00
|
|
|
case STATUS_REVISIONS_LOAD_SUCCESS:
|
2020-11-25 21:22:37 +00:00
|
|
|
return state.withMutations((mutable) => {
|
2020-03-27 22:57:03 +00:00
|
|
|
mutable.set('loading', false)
|
|
|
|
mutable.set('revisions', fromJS(action.revisions).reverse())
|
|
|
|
})
|
|
|
|
case STATUS_REVISIONS_LOAD_FAIL:
|
2020-11-25 21:22:37 +00:00
|
|
|
return state.withMutations((mutable) => {
|
2020-03-27 22:57:03 +00:00
|
|
|
mutable.set('loading', false)
|
|
|
|
mutable.set('error', action.error)
|
|
|
|
})
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|