Batch-resolves channel page query
Closes 5597: batch resolves on channel search page Do a batch-resolve immediate after getting the results and before setting the result variable, as the latter would result in the Claim* components resolving individually. I enabled `returnCachedClaims` -- I assumed that's a reasonable thing to do. I don't see other places use it, though, so highlighting it here.
This commit is contained in:
parent
05383701af
commit
c92fc2e16b
2 changed files with 13 additions and 1 deletions
|
@ -6,6 +6,7 @@ import {
|
|||
makeSelectClaimIsMine,
|
||||
makeSelectTotalPagesInChannelSearch,
|
||||
makeSelectClaimForUri,
|
||||
doResolveUris,
|
||||
SETTINGS,
|
||||
} from 'lbry-redux';
|
||||
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
|
||||
|
@ -32,4 +33,8 @@ const select = (state, props) => {
|
|||
};
|
||||
};
|
||||
|
||||
export default withRouter(connect(select)(ChannelPage));
|
||||
const perform = (dispatch) => ({
|
||||
doResolveUris: (uris) => dispatch(doResolveUris(uris)),
|
||||
});
|
||||
|
||||
export default withRouter(connect(select, perform)(ChannelPage));
|
||||
|
|
|
@ -30,6 +30,7 @@ type Props = {
|
|||
showMature: boolean,
|
||||
tileLayout: boolean,
|
||||
viewHiddenChannels: boolean,
|
||||
doResolveUris: (Array<string>, boolean) => void,
|
||||
};
|
||||
|
||||
function ChannelContent(props: Props) {
|
||||
|
@ -46,6 +47,7 @@ function ChannelContent(props: Props) {
|
|||
showMature,
|
||||
tileLayout,
|
||||
viewHiddenChannels,
|
||||
doResolveUris,
|
||||
} = props;
|
||||
const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0;
|
||||
const [searchQuery, setSearchQuery] = React.useState('');
|
||||
|
@ -78,6 +80,11 @@ function ChannelContent(props: Props) {
|
|||
return `lbry://${name}#${claimId}`;
|
||||
});
|
||||
|
||||
// Batch-resolve the urls before calling 'setSearchResults', as the
|
||||
// latter will immediately cause the tiles to resolve, ending up
|
||||
// calling doResolveUri one by one before the batched one.
|
||||
doResolveUris(urls, true);
|
||||
|
||||
setSearchResults(urls);
|
||||
})
|
||||
.catch(() => {
|
||||
|
|
Loading…
Reference in a new issue