diff --git a/src/utils/downloader/EntityDownloader.ts b/src/utils/downloader/EntityDownloader.ts index 25e6121b7..4b850dd6d 100644 --- a/src/utils/downloader/EntityDownloader.ts +++ b/src/utils/downloader/EntityDownloader.ts @@ -28,6 +28,7 @@ export abstract class EntityDownloader { private entities: E[] = [] private readonly downloadedCountRef = ref(0) + private readonly firstDownloadedEntityRef: Ref = ref(null) private readonly lastDownloadedEntityRef: Ref = ref(null) private readonly drainedRef = ref(false) private readonly stateRef: Ref = ref(DownloaderState.Fresh) @@ -66,6 +67,8 @@ export abstract class EntityDownloader { public downloadedCount: ComputedRef = computed(() => this.downloadedCountRef.value) + public firstDownloadedEntity: ComputedRef + = computed(() => this.firstDownloadedEntityRef.value) public lastDownloadedEntity: ComputedRef = computed(() => this.lastDownloadedEntityRef.value) public drained: ComputedRef @@ -128,6 +131,8 @@ export abstract class EntityDownloader { = this.entities.concat(newEntities) this.downloadedCountRef.value = this.entities.length + this.firstDownloadedEntityRef.value + = this.entities.length >= 1 ? this.entities[0] : null this.lastDownloadedEntityRef.value = this.entities.length >= 1 ? this.entities[this.entities.length - 1] : null diff --git a/src/utils/downloader/TransactionDownloader.ts b/src/utils/downloader/TransactionDownloader.ts index 86530623d..0e05c2277 100644 --- a/src/utils/downloader/TransactionDownloader.ts +++ b/src/utils/downloader/TransactionDownloader.ts @@ -51,19 +51,24 @@ export class TransactionDownloader extends EntityDownloader now - startTime lastTime endTime + | remaining | already | nothing | + | to download | downloaded | here | + --------+-----------------------+------------------------+---------+--------> now + startTime lastTime firstTime endTime */ - const progress = lastTime !== null ? (endTime - lastTime) / (endTime - startTime) : 0 - result = Math.round(progress * 100) / 100 + const progress = firstTime !== null && lastTime !== null + ? (firstTime - lastTime) / (firstTime - startTime) : 0 + result = Math.round(progress * 1000) / 1000 } return result