Adapt web client to consume new server response format
This commit is contained in:
@@ -14,9 +14,8 @@ import {
|
||||
getAssetInfo,
|
||||
getTimeBucket,
|
||||
getTimeBuckets,
|
||||
TimeBucketSize,
|
||||
type AssetResponseDto,
|
||||
type AssetStackResponseDto,
|
||||
type TimeBucketResponseDto,
|
||||
} from '@immich/sdk';
|
||||
import { clamp, debounce, isEqual, throttle } from 'lodash-es';
|
||||
import { DateTime } from 'luxon';
|
||||
@@ -84,7 +83,7 @@ export type TimelineAsset = {
|
||||
duration: string | null;
|
||||
projectionType: string | null;
|
||||
livePhotoVideoId: string | null;
|
||||
text: {
|
||||
description: {
|
||||
city: string | null;
|
||||
country: string | null;
|
||||
people: string[];
|
||||
@@ -418,11 +417,34 @@ export class AssetBucket {
|
||||
};
|
||||
}
|
||||
|
||||
#decodeString(stringOrNumber: string | number) {
|
||||
return typeof stringOrNumber === 'number' ? null : (stringOrNumber as string);
|
||||
}
|
||||
|
||||
// note - if the assets are not part of this bucket, they will not be added
|
||||
addAssets(bucketResponse: AssetResponseDto[]) {
|
||||
addAssets(bucketResponse: TimeBucketResponseDto) {
|
||||
const addContext = new AddContext();
|
||||
for (const asset of bucketResponse) {
|
||||
const timelineAsset = toTimelineAsset(asset);
|
||||
for (let i = 0; i < bucketResponse.bucketAssets.id.length; i++) {
|
||||
const timelineAsset: TimelineAsset = {
|
||||
description: {
|
||||
...bucketResponse.bucketAssets.description[i],
|
||||
people: [],
|
||||
},
|
||||
duration: this.#decodeString(bucketResponse.bucketAssets.duration[i]),
|
||||
id: bucketResponse.bucketAssets.id[i],
|
||||
isArchived: !!bucketResponse.bucketAssets.isArchived[i],
|
||||
isFavorite: !!bucketResponse.bucketAssets.isFavorite[i],
|
||||
isImage: !!bucketResponse.bucketAssets.isImage[i],
|
||||
isTrashed: !!bucketResponse.bucketAssets.isTrashed[i],
|
||||
isVideo: !!bucketResponse.bucketAssets.isVideo[i],
|
||||
livePhotoVideoId: this.#decodeString(bucketResponse.bucketAssets.livePhotoVideoId[i]),
|
||||
localDateTime: bucketResponse.bucketAssets.localDateTime[i],
|
||||
ownerId: bucketResponse.bucketAssets.ownerId[i],
|
||||
projectionType: this.#decodeString(bucketResponse.bucketAssets.projectionType[i]),
|
||||
ratio: bucketResponse.bucketAssets.ratio[i],
|
||||
stack: bucketResponse.bucketAssets.stack[i],
|
||||
thumbhash: this.#decodeString(bucketResponse.bucketAssets.thumbhash[i]),
|
||||
};
|
||||
this.addTimelineAsset(timelineAsset, addContext);
|
||||
}
|
||||
|
||||
@@ -878,7 +900,6 @@ export class AssetStore {
|
||||
async #initialiazeTimeBuckets() {
|
||||
const timebuckets = await getTimeBuckets({
|
||||
...this.#options,
|
||||
size: TimeBucketSize.Month,
|
||||
key: authManager.key,
|
||||
});
|
||||
|
||||
@@ -1086,7 +1107,7 @@ export class AssetStore {
|
||||
{
|
||||
...this.#options,
|
||||
timeBucket: bucketDate,
|
||||
size: TimeBucketSize.Month,
|
||||
|
||||
key: authManager.key,
|
||||
},
|
||||
{ signal },
|
||||
@@ -1097,12 +1118,11 @@ export class AssetStore {
|
||||
{
|
||||
albumId: this.#options.timelineAlbumId,
|
||||
timeBucket: bucketDate,
|
||||
size: TimeBucketSize.Month,
|
||||
key: authManager.key,
|
||||
},
|
||||
{ signal },
|
||||
);
|
||||
for (const { id } of albumAssets) {
|
||||
for (const id of albumAssets.bucketAssets.id) {
|
||||
this.albumAssets.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user