2025-10-27 20:02:52 +05:30
|
|
|
import 'dart:async';
|
|
|
|
|
|
2025-09-19 19:17:56 +05:30
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2025-06-30 12:21:09 -05:00
|
|
|
import 'package:immich_mobile/infrastructure/repositories/remote_asset.repository.dart';
|
2025-07-02 00:52:11 +08:00
|
|
|
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
2025-06-30 12:21:09 -05:00
|
|
|
import 'package:immich_mobile/repositories/asset_api.repository.dart';
|
|
|
|
|
|
|
|
|
|
final actionServiceProvider = Provider<ActionService>(
|
2026-08-01 08:06:43 +05:30
|
|
|
(ref) => ActionService(ref.watch(assetApiRepositoryProvider), ref.watch(remoteAssetRepositoryProvider)),
|
2025-06-30 12:21:09 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
class ActionService {
|
|
|
|
|
final AssetApiRepository _assetApiRepository;
|
2025-07-02 23:54:37 +05:30
|
|
|
final RemoteAssetRepository _remoteAssetRepository;
|
2025-06-30 12:21:09 -05:00
|
|
|
|
2026-08-01 08:06:43 +05:30
|
|
|
const ActionService(this._assetApiRepository, this._remoteAssetRepository);
|
2025-06-30 12:21:09 -05:00
|
|
|
|
2026-05-12 21:56:19 +02:00
|
|
|
Future<int> emptyTrash(String userId) async {
|
|
|
|
|
final count = await _assetApiRepository.emptyTrash();
|
|
|
|
|
await _remoteAssetRepository.emptyTrash(userId);
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<int> restoreAllTrash(String userId) async {
|
|
|
|
|
final count = await _assetApiRepository.restoreAllTrash();
|
|
|
|
|
await _remoteAssetRepository.restoreAllTrash(userId);
|
|
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-29 16:17:33 -05:00
|
|
|
Future<bool> updateDescription(String assetId, String description) async {
|
|
|
|
|
// update remote first, then local to ensure consistency
|
|
|
|
|
await _assetApiRepository.updateDescription(assetId, description);
|
|
|
|
|
await _remoteAssetRepository.updateDescription(assetId, description);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 19:06:28 +02:00
|
|
|
Future<bool> updateRating(String assetId, int? rating) async {
|
2026-01-23 16:47:46 +01:00
|
|
|
// update remote first, then local to ensure consistency
|
|
|
|
|
await _assetApiRepository.updateRating(assetId, rating);
|
|
|
|
|
await _remoteAssetRepository.updateRating(assetId, rating);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-06-30 12:21:09 -05:00
|
|
|
}
|