handle claimsInChannels for channel fetch so pagination always w… (#246)

handle claimsInChannels for channel fetch so pagination always works
This commit is contained in:
Sean Yesmunt 2019-11-19 16:32:52 -05:00 committed by GitHub
commit 71b2acb82c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 7 deletions

13
dist/bundle.es.js vendored
View file

@ -2732,13 +2732,14 @@ function doFetchClaimsByChannel(uri, page = 1) {
page: page || 1,
order_by: ['release_time']
}).then(result => {
const { items: claimsInChannel, page: returnedPage } = result;
const { items: claims, total_items: claimsInChannel, page: returnedPage } = result;
dispatch({
type: FETCH_CHANNEL_CLAIMS_COMPLETED,
data: {
uri,
claims: claimsInChannel || [],
claimsInChannel,
claims: claims || [],
page: returnedPage || undefined
}
});
@ -4172,9 +4173,10 @@ reducers[FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => {
const {
uri,
claims,
claimsInChannel,
page
} = action.data;
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
const claimsByChannel = Object.assign({}, state.claimsByChannel);
const byChannel = Object.assign({}, claimsByChannel[uri]);
const allClaimIds = new Set(byChannel.all);
@ -4192,6 +4194,10 @@ reducers[FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => {
});
}
if (claimsInChannel) {
channelClaimCounts[uri] = claimsInChannel;
}
byChannel.all = allClaimIds;
byChannel[page] = currentPageClaimIds;
claimsByChannel[uri] = byChannel;
@ -4202,6 +4208,7 @@ reducers[FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => {
byId,
fetchingChannelClaims,
claimsByUri,
channelClaimCounts,
currentChannelPage: page
});
};

View file

@ -221,13 +221,14 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1) {
page: page || 1,
order_by: ['release_time'],
}).then((result: ClaimSearchResponse) => {
const { items: claimsInChannel, page: returnedPage } = result;
const { items: claims, total_items: claimsInChannel, page: returnedPage } = result;
dispatch({
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
data: {
uri,
claims: claimsInChannel || [],
claimsInChannel,
claims: claims || [],
page: returnedPage || undefined,
},
});

View file

@ -246,9 +246,15 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any):
const {
uri,
claims,
claimsInChannel,
page,
}: { uri: string, claims: Array<StreamClaim>, page: number } = action.data;
}: {
uri: string,
claims: Array<StreamClaim>,
claimsInChannel?: number,
page: number,
} = action.data;
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
const claimsByChannel = Object.assign({}, state.claimsByChannel);
const byChannel = Object.assign({}, claimsByChannel[uri]);
const allClaimIds = new Set(byChannel.all);
@ -266,6 +272,10 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any):
});
}
if (claimsInChannel) {
channelClaimCounts[uri] = claimsInChannel;
}
byChannel.all = allClaimIds;
byChannel[page] = currentPageClaimIds;
claimsByChannel[uri] = byChannel;
@ -276,6 +286,7 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any):
byId,
fetchingChannelClaims,
claimsByUri,
channelClaimCounts,
currentChannelPage: page,
});
};