fix(web): prevent duplicate time bucket loads (#8091)

This commit is contained in:
Michel Heusschen
2024-03-20 20:40:41 +01:00
committed by GitHub
parent ec9a6bca14
commit 048d437b0b
3 changed files with 53 additions and 20 deletions
+16 -14
View File
@@ -229,21 +229,21 @@ export class AssetStore {
}
async loadBucket(bucketDate: string, position: BucketPosition): Promise<void> {
const bucket = this.getBucketByDate(bucketDate);
if (!bucket) {
return;
}
bucket.position = position;
if (bucket.cancelToken || bucket.assets.length > 0) {
this.emit(false);
return;
}
bucket.cancelToken = new AbortController();
try {
const bucket = this.getBucketByDate(bucketDate);
if (!bucket) {
return;
}
bucket.position = position;
if (bucket.assets.length > 0) {
this.emit(false);
return;
}
bucket.cancelToken = new AbortController();
const assets = await getTimeBucket(
{
...this.options,
@@ -278,6 +278,8 @@ export class AssetStore {
this.emit(true);
} catch (error) {
handleError(error, 'Failed to load assets');
} finally {
bucket.cancelToken = null;
}
}