review
This commit is contained in:
parent
f5f3bf21ee
commit
bd62a55608
4 changed files with 22 additions and 22 deletions
2
flow-typed/livestream.js
vendored
2
flow-typed/livestream.js
vendored
|
@ -22,5 +22,5 @@ declare type LivestreamReplayItem = {
|
|||
declare type LivestreamReplayData = Array<LivestreamReplayItem>;
|
||||
|
||||
declare type LivestreamState = {
|
||||
idsFetching: {},
|
||||
fetchingById: {},
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ export const doFetchNoSourceClaims = (channelId: string) => async (dispatch: Dis
|
|||
type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED,
|
||||
data: channelId,
|
||||
});
|
||||
|
||||
const items = await dispatch(
|
||||
try {
|
||||
await dispatch(
|
||||
doClaimSearch({
|
||||
channel_ids: [channelId],
|
||||
has_no_source: true,
|
||||
|
@ -19,12 +19,12 @@ export const doFetchNoSourceClaims = (channelId: string) => async (dispatch: Dis
|
|||
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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]));
|
||||
|
|
Loading…
Reference in a new issue