diff --git a/flow-typed/livestream.js b/flow-typed/livestream.js index 75218e035..be888611e 100644 --- a/flow-typed/livestream.js +++ b/flow-typed/livestream.js @@ -22,5 +22,5 @@ declare type LivestreamReplayItem = { declare type LivestreamReplayData = Array; declare type LivestreamState = { - idsFetching: {}, + fetchingById: {}, } diff --git a/ui/redux/actions/livestream.js b/ui/redux/actions/livestream.js index bd84be2aa..c33d3ebc7 100644 --- a/ui/redux/actions/livestream.js +++ b/ui/redux/actions/livestream.js @@ -7,24 +7,24 @@ export const doFetchNoSourceClaims = (channelId: string) => async (dispatch: Dis type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED, data: channelId, }); + try { + await dispatch( + doClaimSearch({ + channel_ids: [channelId], + has_no_source: true, + claim_type: ['stream'], + no_totals: true, + page_size: 20, + page: 1, + include_is_my_output: true, + }) + ); - const items = await dispatch( - doClaimSearch({ - channel_ids: [channelId], - has_no_source: true, - claim_type: ['stream'], - no_totals: true, - page_size: 20, - page: 1, - include_is_my_output: true, - }) - ); - if (items) { dispatch({ type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_COMPLETED, data: channelId, }); - } else { + } catch (error) { dispatch({ type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_FAILED, data: channelId, diff --git a/ui/redux/reducers/livestream.js b/ui/redux/reducers/livestream.js index 94619791d..ce339e4a3 100644 --- a/ui/redux/reducers/livestream.js +++ b/ui/redux/reducers/livestream.js @@ -3,31 +3,31 @@ import * as ACTIONS from 'constants/action_types'; import { handleActions } from 'util/redux-utils'; const defaultState: LivestreamState = { - idsFetching: {}, + fetchingById: {}, }; export default handleActions( { [ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED]: (state: LivestreamState, action: any): LivestreamState => { const claimId = action.data; - const newIdsFetching = Object.assign({}, state.idsFetching); + const newIdsFetching = Object.assign({}, state.fetchingById); newIdsFetching[claimId] = true; - return { ...state, idsFetching: newIdsFetching }; + return { ...state, fetchingById: newIdsFetching }; }, [ACTIONS.FETCH_NO_SOURCE_CLAIMS_COMPLETED]: (state: LivestreamState, action: any): LivestreamState => { const claimId = action.data; - const newIdsFetching = Object.assign({}, state.idsFetching); + const newIdsFetching = Object.assign({}, state.fetchingById); newIdsFetching[claimId] = false; - return { ...state, idsFetching: newIdsFetching }; + return { ...state, fetchingById: newIdsFetching }; }, [ACTIONS.FETCH_NO_SOURCE_CLAIMS_FAILED]: (state: LivestreamState, action: any) => { const claimId = action.data; - const newIdsFetching = Object.assign({}, state.idsFetching); + const newIdsFetching = Object.assign({}, state.fetchingById); newIdsFetching[claimId] = false; - return { ...state, idsFetching: newIdsFetching }; + return { ...state, fetchingById: newIdsFetching }; }, }, defaultState diff --git a/ui/redux/selectors/livestream.js b/ui/redux/selectors/livestream.js index 98cdb9d04..11280b0e2 100644 --- a/ui/redux/selectors/livestream.js +++ b/ui/redux/selectors/livestream.js @@ -20,7 +20,7 @@ export const makeSelectLivestreamsForChannelId = (channelId: string) => .sort((a, b) => b.timestamp - a.timestamp); // newest first }); -export const selectFetchingLivestreams = createSelector(selectState, (state) => state.idsFetching); +export const selectFetchingLivestreams = createSelector(selectState, (state) => state.fetchingById); export const makeSelectIsFetchingLivestreams = (channelId: string) => createSelector(selectFetchingLivestreams, (fetchingLivestreams) => Boolean(fetchingLivestreams[channelId]));