mirror of
https://github.com/immich-app/immich.git
synced 2025-08-11 09:16:31 -04:00
* chore: bump dart sdk to 3.8 * chore: make build * make pigeon * chore: format files --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
36 lines
1.2 KiB
Dart
36 lines
1.2 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.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';
|
|
import 'package:logging/logging.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final folderApiRepositoryProvider = Provider((ref) => FolderApiRepository(ref.watch(apiServiceProvider).viewApi));
|
|
|
|
class FolderApiRepository extends ApiRepository {
|
|
final ViewApi _api;
|
|
final Logger _log = Logger("FolderApiRepository");
|
|
|
|
FolderApiRepository(this._api);
|
|
|
|
Future<List<String>> getAllUniquePaths() async {
|
|
try {
|
|
final list = await _api.getUniqueOriginalPaths();
|
|
return list ?? [];
|
|
} catch (e, stack) {
|
|
_log.severe("Failed to fetch unique original links", e, stack);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
Future<List<Asset>> getAssetsForPath(String? path) async {
|
|
try {
|
|
final list = await _api.getAssetsByOriginalPath(path ?? '/');
|
|
return list != null ? list.map(Asset.remote).toList() : [];
|
|
} catch (e, stack) {
|
|
_log.severe("Failed to fetch Assets by original path", e, stack);
|
|
return [];
|
|
}
|
|
}
|
|
}
|