mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat: show stacks in asset viewer (#19935)
* feat: show stacks in asset viewer * fix: global key issue and flash on stack asset change * feat(mobile): stack and unstack action (#19941) * feat(mobile): stack and unstack action * add custom model * use stackId from ActionSource * Update mobile/lib/providers/infrastructure/action.provider.dart Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> --------- Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> * fix: lint * fix: bad merge * fix: test --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Daimolean <92239625+wuzihao051119@users.noreply.github.com> Co-authored-by: wuzihao051119 <wuzihao051119@outlook.com>
This commit is contained in:
parent
546f841b2c
commit
f32cd74232
41 changed files with 1568 additions and 802 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/domain/models/stack.model.dart';
|
||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||
import 'package:immich_mobile/providers/api.provider.dart';
|
||||
import 'package:immich_mobile/repositories/api.repository.dart';
|
||||
|
|
@ -11,14 +12,16 @@ final assetApiRepositoryProvider = Provider(
|
|||
(ref) => AssetApiRepository(
|
||||
ref.watch(apiServiceProvider).assetsApi,
|
||||
ref.watch(apiServiceProvider).searchApi,
|
||||
ref.watch(apiServiceProvider).stacksApi,
|
||||
),
|
||||
);
|
||||
|
||||
class AssetApiRepository extends ApiRepository {
|
||||
final AssetsApi _api;
|
||||
final SearchApi _searchApi;
|
||||
final StacksApi _stacksApi;
|
||||
|
||||
AssetApiRepository(this._api, this._searchApi);
|
||||
AssetApiRepository(this._api, this._searchApi, this._stacksApi);
|
||||
|
||||
Future<Asset> update(String id, {String? description}) async {
|
||||
final response = await checkNull(
|
||||
|
|
@ -84,6 +87,17 @@ class AssetApiRepository extends ApiRepository {
|
|||
);
|
||||
}
|
||||
|
||||
Future<StackResponse> stack(List<String> ids) async {
|
||||
final responseDto =
|
||||
await checkNull(_stacksApi.createStack(StackCreateDto(assetIds: ids)));
|
||||
|
||||
return responseDto.toStack();
|
||||
}
|
||||
|
||||
Future<void> unStack(List<String> ids) async {
|
||||
return _stacksApi.deleteStacks(BulkIdsDto(ids: ids));
|
||||
}
|
||||
|
||||
Future<Response> downloadAsset(String id) {
|
||||
return _api.downloadAssetWithHttpInfo(id);
|
||||
}
|
||||
|
|
@ -102,3 +116,13 @@ class AssetApiRepository extends ApiRepository {
|
|||
return response.originalMimeType;
|
||||
}
|
||||
}
|
||||
|
||||
extension on StackResponseDto {
|
||||
StackResponse toStack() {
|
||||
return StackResponse(
|
||||
id: id,
|
||||
primaryAssetId: primaryAssetId,
|
||||
assetIds: assets.map((asset) => asset.id).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue