mirror of
https://github.com/immich-app/immich.git
synced 2024-12-21 01:39:59 +02:00
0d0866d5d9
* Add API service * Added service, provider * merge main * update pubspec * styling * dev: add person search result page * dev: display person asset on page * dev: add rename form * style form * dev: mechanism to add name to faces * styling * fix bad merge * update api * test * revert * Add header widget * change name * show all people page * fix test * pr feedback * Add name to app bar * feedback * styling
45 lines
1.3 KiB
Dart
45 lines
1.3 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/modules/home/ui/asset_grid/asset_grid_data_structure.dart';
|
|
import 'package:immich_mobile/modules/search/services/person.service.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final personAssetsProvider = FutureProvider.family
|
|
.autoDispose<RenderList, String>((ref, personId) async {
|
|
final PersonService personService = ref.watch(personServiceProvider);
|
|
|
|
final assets = await personService.getPersonAssets(personId);
|
|
|
|
if (assets == null) {
|
|
return RenderList.empty();
|
|
}
|
|
|
|
return RenderList.fromAssets(assets, GroupAssetsBy.auto);
|
|
});
|
|
|
|
final getCuratedPeopleProvider =
|
|
FutureProvider.autoDispose<List<PersonResponseDto>>((ref) async {
|
|
final PersonService personService = ref.watch(personServiceProvider);
|
|
|
|
final curatedPeople = await personService.getCuratedPeople();
|
|
|
|
return curatedPeople ?? [];
|
|
});
|
|
|
|
class UpdatePersonName {
|
|
final String id;
|
|
final String name;
|
|
|
|
UpdatePersonName(this.id, this.name);
|
|
}
|
|
|
|
final updatePersonNameProvider =
|
|
StateProvider.family<void, UpdatePersonName>((ref, dto) async {
|
|
final PersonService personService = ref.watch(personServiceProvider);
|
|
|
|
final person = await personService.updateName(dto.id, dto.name);
|
|
|
|
if (person != null && person.name == dto.name) {
|
|
ref.invalidate(getCuratedPeopleProvider);
|
|
}
|
|
});
|