Fix explorer history refresh (#12443)

This commit is contained in:
Justin Starry
2020-09-24 14:27:28 +08:00
committed by GitHub
parent 586501bb5e
commit ba7f7cca78

View File

@ -28,15 +28,23 @@ function combineFetched(
current: ConfirmedSignatureInfo[] | undefined, current: ConfirmedSignatureInfo[] | undefined,
before: TransactionSignature | undefined before: TransactionSignature | undefined
) { ) {
if (current === undefined) { if (current === undefined || current.length === 0) {
return fetched; return fetched;
} }
if (current.length > 0 && current[current.length - 1].signature === before) { // History was refreshed, fetch results should be prepended if contiguous
return current.concat(fetched); if (before === undefined) {
} else { const end = fetched.findIndex((f) => f.signature === current[0].signature);
return fetched; if (end < 0) return fetched;
return fetched.slice(0, end).concat(current);
} }
// More history was loaded, fetch results should be appended
if (current[current.length - 1].signature === before) {
return current.concat(fetched);
}
return fetched;
} }
function reconcile( function reconcile(