madiator.com/ui/redux/reducers/livestream.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-08-16 12:11:25 +02:00
// @flow
import * as ACTIONS from 'constants/action_types';
import { handleActions } from 'util/redux-utils';
const defaultState: LivestreamState = {
fetchingById: {},
};
export default handleActions(
{
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED]: (state: LivestreamState, action: any): LivestreamState => {
const claimId = action.data;
const newIdsFetching = Object.assign({}, state.fetchingById);
newIdsFetching[claimId] = true;
return { ...state, fetchingById: newIdsFetching };
},
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_COMPLETED]: (state: LivestreamState, action: any): LivestreamState => {
const claimId = action.data;
const newIdsFetching = Object.assign({}, state.fetchingById);
newIdsFetching[claimId] = false;
return { ...state, fetchingById: newIdsFetching };
},
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_FAILED]: (state: LivestreamState, action: any) => {
const claimId = action.data;
const newIdsFetching = Object.assign({}, state.fetchingById);
newIdsFetching[claimId] = false;
return { ...state, fetchingById: newIdsFetching };
},
},
defaultState
);