fix(web): prevent fetching asset info twice (#8486)

This commit is contained in:
Michel Heusschen 2024-04-04 03:20:54 +02:00 committed by GitHub
parent 0529076ed7
commit 66650f5944
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 47 additions and 61 deletions

View file

@ -451,7 +451,7 @@ export class AssetStore {
this.emit(true);
}
async getPreviousAssetId(assetId: string): Promise<string | null> {
async getPreviousAsset(assetId: string): Promise<AssetResponseDto | null> {
const info = this.getBucketInfoForAssetId(assetId);
if (!info) {
return null;
@ -460,7 +460,7 @@ export class AssetStore {
const { bucket, assetIndex, bucketIndex } = info;
if (assetIndex !== 0) {
return bucket.assets[assetIndex - 1].id;
return bucket.assets[assetIndex - 1];
}
if (bucketIndex === 0) {
@ -469,10 +469,10 @@ export class AssetStore {
const previousBucket = this.buckets[bucketIndex - 1];
await this.loadBucket(previousBucket.bucketDate, BucketPosition.Unknown);
return previousBucket.assets.at(-1)?.id || null;
return previousBucket.assets.at(-1) || null;
}
async getNextAssetId(assetId: string): Promise<string | null> {
async getNextAsset(assetId: string): Promise<AssetResponseDto | null> {
const info = this.getBucketInfoForAssetId(assetId);
if (!info) {
return null;
@ -481,7 +481,7 @@ export class AssetStore {
const { bucket, assetIndex, bucketIndex } = info;
if (assetIndex !== bucket.assets.length - 1) {
return bucket.assets[assetIndex + 1].id;
return bucket.assets[assetIndex + 1];
}
if (bucketIndex === this.buckets.length - 1) {
@ -490,7 +490,7 @@ export class AssetStore {
const nextBucket = this.buckets[bucketIndex + 1];
await this.loadBucket(nextBucket.bucketDate, BucketPosition.Unknown);
return nextBucket.assets[0]?.id || null;
return nextBucket.assets[0] || null;
}
triggerUpdate() {