handle claimsInChannels for channel fetch so pagination always works
This commit is contained in:
parent
f5a62363cf
commit
c30889d339
3 changed files with 26 additions and 7 deletions
13
dist/bundle.es.js
vendored
13
dist/bundle.es.js
vendored
|
@ -2732,13 +2732,14 @@ function doFetchClaimsByChannel(uri, page = 1) {
|
||||||
page: page || 1,
|
page: page || 1,
|
||||||
order_by: ['release_time']
|
order_by: ['release_time']
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
const { items: claimsInChannel, page: returnedPage } = result;
|
const { items: claims, total_items: claimsInChannel, page: returnedPage } = result;
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: FETCH_CHANNEL_CLAIMS_COMPLETED,
|
type: FETCH_CHANNEL_CLAIMS_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
claims: claimsInChannel || [],
|
claimsInChannel,
|
||||||
|
claims: claims || [],
|
||||||
page: returnedPage || undefined
|
page: returnedPage || undefined
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -4172,9 +4173,10 @@ reducers[FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => {
|
||||||
const {
|
const {
|
||||||
uri,
|
uri,
|
||||||
claims,
|
claims,
|
||||||
|
claimsInChannel,
|
||||||
page
|
page
|
||||||
} = action.data;
|
} = action.data;
|
||||||
|
const channelClaimCounts = Object.assign({}, state.channelClaimCounts);
|
||||||
const claimsByChannel = Object.assign({}, state.claimsByChannel);
|
const claimsByChannel = Object.assign({}, state.claimsByChannel);
|
||||||
const byChannel = Object.assign({}, claimsByChannel[uri]);
|
const byChannel = Object.assign({}, claimsByChannel[uri]);
|
||||||
const allClaimIds = new Set(byChannel.all);
|
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.all = allClaimIds;
|
||||||
byChannel[page] = currentPageClaimIds;
|
byChannel[page] = currentPageClaimIds;
|
||||||
claimsByChannel[uri] = byChannel;
|
claimsByChannel[uri] = byChannel;
|
||||||
|
@ -4202,6 +4208,7 @@ reducers[FETCH_CHANNEL_CLAIMS_COMPLETED] = (state, action) => {
|
||||||
byId,
|
byId,
|
||||||
fetchingChannelClaims,
|
fetchingChannelClaims,
|
||||||
claimsByUri,
|
claimsByUri,
|
||||||
|
channelClaimCounts,
|
||||||
currentChannelPage: page
|
currentChannelPage: page
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -221,13 +221,14 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1) {
|
||||||
page: page || 1,
|
page: page || 1,
|
||||||
order_by: ['release_time'],
|
order_by: ['release_time'],
|
||||||
}).then((result: ClaimSearchResponse) => {
|
}).then((result: ClaimSearchResponse) => {
|
||||||
const { items: claimsInChannel, page: returnedPage } = result;
|
const { items: claims, total_items: claimsInChannel, page: returnedPage } = result;
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
|
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
claims: claimsInChannel || [],
|
claimsInChannel,
|
||||||
|
claims: claims || [],
|
||||||
page: returnedPage || undefined,
|
page: returnedPage || undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -246,9 +246,15 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any):
|
||||||
const {
|
const {
|
||||||
uri,
|
uri,
|
||||||
claims,
|
claims,
|
||||||
|
claimsInChannel,
|
||||||
page,
|
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 claimsByChannel = Object.assign({}, state.claimsByChannel);
|
||||||
const byChannel = Object.assign({}, claimsByChannel[uri]);
|
const byChannel = Object.assign({}, claimsByChannel[uri]);
|
||||||
const allClaimIds = new Set(byChannel.all);
|
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.all = allClaimIds;
|
||||||
byChannel[page] = currentPageClaimIds;
|
byChannel[page] = currentPageClaimIds;
|
||||||
claimsByChannel[uri] = byChannel;
|
claimsByChannel[uri] = byChannel;
|
||||||
|
@ -276,6 +286,7 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any):
|
||||||
byId,
|
byId,
|
||||||
fetchingChannelClaims,
|
fetchingChannelClaims,
|
||||||
claimsByUri,
|
claimsByUri,
|
||||||
|
channelClaimCounts,
|
||||||
currentChannelPage: page,
|
currentChannelPage: page,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue