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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

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