You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-08 23:07:06 +02:00
refactor(mobile): use repositories in a number of services (#12891)
* UserService * PartnerService * HashService * MemoryService * PersonService * SearchService * StackService
This commit is contained in:
committed by
GitHub
parent
e0fa3cdbc7
commit
202082f62e
@ -6,14 +6,18 @@ import 'package:immich_mobile/repositories/base_api.repository.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final assetApiRepositoryProvider = Provider(
|
||||
(ref) => AssetApiRepository(ref.watch(apiServiceProvider).assetsApi),
|
||||
(ref) => AssetApiRepository(
|
||||
ref.watch(apiServiceProvider).assetsApi,
|
||||
ref.watch(apiServiceProvider).searchApi,
|
||||
),
|
||||
);
|
||||
|
||||
class AssetApiRepository extends BaseApiRepository
|
||||
implements IAssetApiRepository {
|
||||
final AssetsApi _api;
|
||||
final SearchApi _searchApi;
|
||||
|
||||
AssetApiRepository(this._api);
|
||||
AssetApiRepository(this._api, this._searchApi);
|
||||
|
||||
@override
|
||||
Future<Asset> update(String id, {String? description}) async {
|
||||
@ -22,4 +26,27 @@ class AssetApiRepository extends BaseApiRepository
|
||||
);
|
||||
return Asset.remote(response);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Asset>> search({List<String> personIds = const []}) async {
|
||||
// TODO this always fetches all assets, change API and usage to actually do pagination
|
||||
final List<Asset> result = [];
|
||||
bool hasNext = true;
|
||||
int currentPage = 1;
|
||||
while (hasNext) {
|
||||
final response = await checkNull(
|
||||
_searchApi.searchMetadata(
|
||||
MetadataSearchDto(
|
||||
personIds: personIds,
|
||||
page: currentPage,
|
||||
size: 1000,
|
||||
),
|
||||
),
|
||||
);
|
||||
result.addAll(response.assets.items.map(Asset.remote));
|
||||
hasNext = response.assets.nextPage != null;
|
||||
currentPage++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user