2025-04-25 05:39:50 +05:30
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2025-10-07 14:18:45 +03:00
|
|
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
2025-06-21 13:35:30 -05:00
|
|
|
import 'package:immich_mobile/services/local_files_manager.service.dart';
|
2025-10-07 14:18:45 +03:00
|
|
|
import 'package:logging/logging.dart';
|
2025-04-25 05:39:50 +05:30
|
|
|
|
2025-06-21 13:35:30 -05:00
|
|
|
final localFilesManagerRepositoryProvider = Provider(
|
2025-07-25 08:07:22 +05:30
|
|
|
(ref) => LocalFilesManagerRepository(ref.watch(localFileManagerServiceProvider)),
|
2025-06-21 13:35:30 -05:00
|
|
|
);
|
2025-04-25 05:39:50 +05:30
|
|
|
|
2025-06-21 13:35:30 -05:00
|
|
|
class LocalFilesManagerRepository {
|
2025-10-07 14:18:45 +03:00
|
|
|
LocalFilesManagerRepository(this._service);
|
2025-06-21 13:35:30 -05:00
|
|
|
|
2025-10-07 14:18:45 +03:00
|
|
|
final Logger _logger = Logger('SyncStreamService');
|
2025-06-21 13:35:30 -05:00
|
|
|
final LocalFilesManagerService _service;
|
2025-04-25 05:39:50 +05:30
|
|
|
|
|
|
|
|
Future<bool> moveToTrash(List<String> mediaUrls) async {
|
2025-06-21 13:35:30 -05:00
|
|
|
return await _service.moveToTrash(mediaUrls);
|
2025-04-25 05:39:50 +05:30
|
|
|
}
|
|
|
|
|
|
2025-09-19 09:14:08 +03:00
|
|
|
Future<bool> restoreFromTrash(String fileName, int type) async {
|
|
|
|
|
return await _service.restoreFromTrash(fileName, type);
|
2025-04-25 05:39:50 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<bool> requestManageMediaPermission() async {
|
2025-06-21 13:35:30 -05:00
|
|
|
return await _service.requestManageMediaPermission();
|
2025-04-25 05:39:50 +05:30
|
|
|
}
|
2025-10-07 14:18:45 +03:00
|
|
|
|
|
|
|
|
Future<List<String>> restoreAssetsFromTrash(Iterable<LocalAsset> assets) async {
|
|
|
|
|
final restoredIds = <String>[];
|
|
|
|
|
for (final asset in assets) {
|
|
|
|
|
_logger.info("Restoring from trash, localId: ${asset.id}, remoteId: ${asset.checksum}");
|
|
|
|
|
try {
|
|
|
|
|
await _service.restoreFromTrashById(asset.id, asset.type.index);
|
|
|
|
|
restoredIds.add(asset.id);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
_logger.warning("Restoring failure: $e");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return restoredIds;
|
|
|
|
|
}
|
2025-04-25 05:39:50 +05:30
|
|
|
}
|