mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
fix(server): update album updatedAt on assets/users removed/added (#1977)
This commit is contained in:
parent
63ad802013
commit
3cce43309c
@ -155,6 +155,7 @@ export class AlbumRepository implements IAlbumRepository {
|
|||||||
|
|
||||||
async addSharedUsers(album: AlbumEntity, addUsersDto: AddUsersDto): Promise<AlbumEntity> {
|
async addSharedUsers(album: AlbumEntity, addUsersDto: AddUsersDto): Promise<AlbumEntity> {
|
||||||
album.sharedUsers.push(...addUsersDto.sharedUserIds.map((id) => ({ id } as UserEntity)));
|
album.sharedUsers.push(...addUsersDto.sharedUserIds.map((id) => ({ id } as UserEntity)));
|
||||||
|
album.updatedAt = new Date().toISOString();
|
||||||
|
|
||||||
await this.albumRepository.save(album);
|
await this.albumRepository.save(album);
|
||||||
|
|
||||||
@ -164,6 +165,7 @@ export class AlbumRepository implements IAlbumRepository {
|
|||||||
|
|
||||||
async removeUser(album: AlbumEntity, userId: string): Promise<void> {
|
async removeUser(album: AlbumEntity, userId: string): Promise<void> {
|
||||||
album.sharedUsers = album.sharedUsers.filter((user) => user.id !== userId);
|
album.sharedUsers = album.sharedUsers.filter((user) => user.id !== userId);
|
||||||
|
album.updatedAt = new Date().toISOString();
|
||||||
await this.albumRepository.save(album);
|
await this.albumRepository.save(album);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,9 +176,13 @@ export class AlbumRepository implements IAlbumRepository {
|
|||||||
return !removeAssetsDto.assetIds.includes(asset.id);
|
return !removeAssetsDto.assetIds.includes(asset.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const numRemovedAssets = assetCount - album.assets.length;
|
||||||
|
if (numRemovedAssets > 0) {
|
||||||
|
album.updatedAt = new Date().toISOString();
|
||||||
|
}
|
||||||
await this.albumRepository.save(album, {});
|
await this.albumRepository.save(album, {});
|
||||||
|
|
||||||
return assetCount - album.assets.length;
|
return numRemovedAssets;
|
||||||
}
|
}
|
||||||
|
|
||||||
async addAssets(album: AlbumEntity, addAssetsDto: AddAssetsDto): Promise<AddAssetsResponseDto> {
|
async addAssets(album: AlbumEntity, addAssetsDto: AddAssetsDto): Promise<AddAssetsResponseDto> {
|
||||||
@ -197,10 +203,14 @@ export class AlbumRepository implements IAlbumRepository {
|
|||||||
album.albumThumbnailAssetId = album.assets[0].id;
|
album.albumThumbnailAssetId = album.assets[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const successfullyAdded = addAssetsDto.assetIds.length - alreadyExisting.length;
|
||||||
|
if (successfullyAdded > 0) {
|
||||||
|
album.updatedAt = new Date().toISOString();
|
||||||
|
}
|
||||||
await this.albumRepository.save(album);
|
await this.albumRepository.save(album);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
successfullyAdded: addAssetsDto.assetIds.length - alreadyExisting.length,
|
successfullyAdded,
|
||||||
alreadyInAlbum: alreadyExisting,
|
alreadyInAlbum: alreadyExisting,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user