This commit is contained in:
zeppi 2021-04-23 13:11:53 -04:00 committed by Sean Yesmunt
parent f5f3bf21ee
commit bd62a55608
4 changed files with 22 additions and 22 deletions

View file

@ -22,5 +22,5 @@ declare type LivestreamReplayItem = {
declare type LivestreamReplayData = Array<LivestreamReplayItem>;
declare type LivestreamState = {
idsFetching: {},
fetchingById: {},
}

View file

@ -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,

View file

@ -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

View file

@ -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]));