Fix grid with adnimation

This commit is contained in:
Raphael Wickihalder 2022-05-29 09:04:34 +02:00 committed by infinite-persistence
parent 29431b1074
commit c6c824c059
2 changed files with 18 additions and 4 deletions

View file

@ -208,17 +208,23 @@ export default function ClaimList(props: Props) {
); );
React.useEffect(() => { React.useEffect(() => {
refreshBuffer();
}, [tileUris, injectedItem, lastVisibleIndex, pageSize]);
function refreshBuffer() {
tileUris.forEach((uri, index) => { tileUris.forEach((uri, index) => {
if (uri) { if (uri) {
const inj = getInjectedItem(index); const inj = getInjectedItem(index);
if (inj) { if (inj) {
if (uriBuffer.indexOf(index) === -1) { if (uriBuffer.indexOf(index) === -1) {
setUriBuffer([index]); let newUriBUffer = uriBuffer;
newUriBUffer.push(index);
setUriBuffer(newUriBUffer);
} }
} }
} }
}); });
}, [tileUris, injectedItem, lastVisibleIndex, pageSize]); }
const getInjectedItem = (index) => { const getInjectedItem = (index) => {
if (injectedItem && injectedItem.node) { if (injectedItem && injectedItem.node) {
@ -243,6 +249,7 @@ export default function ClaimList(props: Props) {
tileUris.map((uri, index) => { tileUris.map((uri, index) => {
if (uri) { if (uri) {
const inj = getInjectedItem(index); const inj = getInjectedItem(index);
if (inj) refreshBuffer();
return ( return (
<React.Fragment key={uri}> <React.Fragment key={uri}>
{inj && inj} {inj && inj}

View file

@ -176,17 +176,23 @@ function ClaimTilesDiscover(props: Props) {
}, [doClaimSearch, shouldPerformSearch, optionsStringified]); }, [doClaimSearch, shouldPerformSearch, optionsStringified]);
React.useEffect(() => { React.useEffect(() => {
refreshBuffer();
}, [finalUris, injectedItem, lastVisibleIndex, pageSize]);
function refreshBuffer() {
finalUris.forEach((uri, index) => { finalUris.forEach((uri, index) => {
if (uri) { if (uri) {
const inj = getInjectedItem(index); const inj = getInjectedItem(index);
if (inj) { if (inj) {
if (uriBuffer.indexOf(index) === -1) { if (uriBuffer.indexOf(index) === -1) {
setUriBuffer([index]); let newUriBUffer = uriBuffer;
newUriBUffer.push(index);
setUriBuffer(newUriBUffer);
} }
} }
} }
}); });
}, [finalUris, injectedItem, lastVisibleIndex, pageSize]); }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -220,6 +226,7 @@ function ClaimTilesDiscover(props: Props) {
? finalUris.map((uri, i) => { ? finalUris.map((uri, i) => {
if (uri) { if (uri) {
const inj = getInjectedItem(i); const inj = getInjectedItem(i);
if (inj) refreshBuffer();
return ( return (
<React.Fragment key={uri}> <React.Fragment key={uri}>
{inj && inj} {inj && inj}