lbry-desktop/ui/redux/reducers/livestream.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

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