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

View file

@ -176,17 +176,23 @@ function ClaimTilesDiscover(props: Props) {
}, [doClaimSearch, shouldPerformSearch, optionsStringified]);
React.useEffect(() => {
refreshBuffer();
}, [finalUris, injectedItem, lastVisibleIndex, pageSize]);
function refreshBuffer() {
finalUris.forEach((uri, index) => {
if (uri) {
const inj = getInjectedItem(index);
if (inj) {
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) => {
if (uri) {
const inj = getInjectedItem(i);
if (inj) refreshBuffer();
return (
<React.Fragment key={uri}>
{inj && inj}