mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(mobile): Add selected assets to album (#901)
* First implementation that uses new API * Various UI improvements * Create new album from home screen * Fix padding when in multiselect mode * Alex Suggestions * Change to album after creation
This commit is contained in:
@@ -46,6 +46,31 @@ class AlbumService {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates names like Untitled, Untitled (1), Untitled (2), ...
|
||||
*/
|
||||
String _getNextAlbumName(List<AlbumResponseDto>? albums) {
|
||||
const baseName = "Untitled";
|
||||
|
||||
if (albums != null) {
|
||||
for (int round = 0; round < albums.length; round++) {
|
||||
final proposedName = "$baseName${round == 0 ? "" : " ($round)"}";
|
||||
|
||||
if (albums.where((a) => a.albumName == proposedName).isEmpty) {
|
||||
return proposedName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseName;
|
||||
}
|
||||
|
||||
Future<AlbumResponseDto?> createAlbumWithGeneratedName(
|
||||
Set<AssetResponseDto> assets,
|
||||
) async {
|
||||
return createAlbum(
|
||||
_getNextAlbumName(await getAlbums(isShared: false)), assets, []);
|
||||
}
|
||||
|
||||
Future<AlbumResponseDto?> getAlbumDetail(String albumId) async {
|
||||
try {
|
||||
return await _apiService.albumApi.getAlbumInfo(albumId);
|
||||
@@ -55,7 +80,7 @@ class AlbumService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> addAdditionalAssetToAlbum(
|
||||
Future<AddAssetsResponseDto?> addAdditionalAssetToAlbum(
|
||||
Set<AssetResponseDto> assets,
|
||||
String albumId,
|
||||
) async {
|
||||
@@ -64,10 +89,10 @@ class AlbumService {
|
||||
albumId,
|
||||
AddAssetsDto(assetIds: assets.map((asset) => asset.id).toList()),
|
||||
);
|
||||
return result != null;
|
||||
return result;
|
||||
} catch (e) {
|
||||
debugPrint("Error addAdditionalAssetToAlbum ${e.toString()}");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user