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 || []);
tileUris = tileUris.filter((uri) => !excludeUris.includes(uri));
const totalLength = tileUris.length;
if (maxClaimRender) tileUris = tileUris.slice(0, maxClaimRender);
let sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || [];
React.useEffect(() => {
if (typeof loadedCallback === 'function') loadedCallback(tileUris.length || 0);
}, [tileUris.length]); // eslint-disable-line react-hooks/exhaustive-deps
if (typeof loadedCallback === 'function') loadedCallback(totalLength);
}, [totalLength]); // eslint-disable-line react-hooks/exhaustive-deps
const noResultMsg = searchInLanguage
? __('No results. Contents may be hidden by the Language filter.')