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 LivestreamReplayData = Array<LivestreamReplayItem>;
|
||||||
|
|
||||||
declare type LivestreamState = {
|
declare type LivestreamState = {
|
||||||
idsFetching: {},
|
fetchingById: {},
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,24 +7,24 @@ export const doFetchNoSourceClaims = (channelId: string) => async (dispatch: Dis
|
||||||
type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED,
|
type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED,
|
||||||
data: channelId,
|
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({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_COMPLETED,
|
type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_COMPLETED,
|
||||||
data: channelId,
|
data: channelId,
|
||||||
});
|
});
|
||||||
} else {
|
} catch (error) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_FAILED,
|
type: ACTIONS.FETCH_NO_SOURCE_CLAIMS_FAILED,
|
||||||
data: channelId,
|
data: channelId,
|
||||||
|
|
|
@ -3,31 +3,31 @@ import * as ACTIONS from 'constants/action_types';
|
||||||
import { handleActions } from 'util/redux-utils';
|
import { handleActions } from 'util/redux-utils';
|
||||||
|
|
||||||
const defaultState: LivestreamState = {
|
const defaultState: LivestreamState = {
|
||||||
idsFetching: {},
|
fetchingById: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default handleActions(
|
export default handleActions(
|
||||||
{
|
{
|
||||||
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED]: (state: LivestreamState, action: any): LivestreamState => {
|
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_STARTED]: (state: LivestreamState, action: any): LivestreamState => {
|
||||||
const claimId = action.data;
|
const claimId = action.data;
|
||||||
const newIdsFetching = Object.assign({}, state.idsFetching);
|
const newIdsFetching = Object.assign({}, state.fetchingById);
|
||||||
newIdsFetching[claimId] = true;
|
newIdsFetching[claimId] = true;
|
||||||
|
|
||||||
return { ...state, idsFetching: newIdsFetching };
|
return { ...state, fetchingById: newIdsFetching };
|
||||||
},
|
},
|
||||||
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_COMPLETED]: (state: LivestreamState, action: any): LivestreamState => {
|
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_COMPLETED]: (state: LivestreamState, action: any): LivestreamState => {
|
||||||
const claimId = action.data;
|
const claimId = action.data;
|
||||||
const newIdsFetching = Object.assign({}, state.idsFetching);
|
const newIdsFetching = Object.assign({}, state.fetchingById);
|
||||||
newIdsFetching[claimId] = false;
|
newIdsFetching[claimId] = false;
|
||||||
|
|
||||||
return { ...state, idsFetching: newIdsFetching };
|
return { ...state, fetchingById: newIdsFetching };
|
||||||
},
|
},
|
||||||
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_FAILED]: (state: LivestreamState, action: any) => {
|
[ACTIONS.FETCH_NO_SOURCE_CLAIMS_FAILED]: (state: LivestreamState, action: any) => {
|
||||||
const claimId = action.data;
|
const claimId = action.data;
|
||||||
const newIdsFetching = Object.assign({}, state.idsFetching);
|
const newIdsFetching = Object.assign({}, state.fetchingById);
|
||||||
newIdsFetching[claimId] = false;
|
newIdsFetching[claimId] = false;
|
||||||
|
|
||||||
return { ...state, idsFetching: newIdsFetching };
|
return { ...state, fetchingById: newIdsFetching };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
defaultState
|
defaultState
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const makeSelectLivestreamsForChannelId = (channelId: string) =>
|
||||||
.sort((a, b) => b.timestamp - a.timestamp); // newest first
|
.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) =>
|
export const makeSelectIsFetchingLivestreams = (channelId: string) =>
|
||||||
createSelector(selectFetchingLivestreams, (fetchingLivestreams) => Boolean(fetchingLivestreams[channelId]));
|
createSelector(selectFetchingLivestreams, (fetchingLivestreams) => Boolean(fetchingLivestreams[channelId]));
|
||||||
|
|
Loading…
Add table
Reference in a new issue