Fix the view more/less functionality by properly reporting the total number of claims (#530)

This commit is contained in:
Dan Peterson 2021-12-17 15:28:11 -06:00 committed by GitHub
parent f0fdcb6a6e
commit 350524114a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,13 +91,16 @@ export default function ClaimList(props: Props) {
let tileUris = (prefixUris || []).concat(uris || []); let tileUris = (prefixUris || []).concat(uris || []);
tileUris = tileUris.filter((uri) => !excludeUris.includes(uri)); tileUris = tileUris.filter((uri) => !excludeUris.includes(uri));
const totalLength = tileUris.length;
if (maxClaimRender) tileUris = tileUris.slice(0, maxClaimRender); if (maxClaimRender) tileUris = tileUris.slice(0, maxClaimRender);
let sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || []; let sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || [];
React.useEffect(() => { React.useEffect(() => {
if (typeof loadedCallback === 'function') loadedCallback(tileUris.length || 0); if (typeof loadedCallback === 'function') loadedCallback(totalLength);
}, [tileUris.length]); // eslint-disable-line react-hooks/exhaustive-deps }, [totalLength]); // eslint-disable-line react-hooks/exhaustive-deps
const noResultMsg = searchInLanguage const noResultMsg = searchInLanguage
? __('No results. Contents may be hidden by the Language filter.') ? __('No results. Contents may be hidden by the Language filter.')