mirror of
https://github.com/immich-app/immich
synced 2026-08-29 13:15:45 +00:00
* chore(mobile): move Drift into mobile/data * Move into more structured subdirectories * Fix changed merge paths
26 lines
1.1 KiB
Dart
26 lines
1.1 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/data/server/api_repository.dart';
|
|
import 'package:immich_mobile/domain/models/person.model.dart';
|
|
import 'package:immich_mobile/providers/api.provider.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final personApiRepositoryProvider = Provider((ref) => PersonApiRepository(ref.watch(apiServiceProvider).peopleApi));
|
|
|
|
class PersonApiRepository extends ApiRepository {
|
|
final PeopleApi _api;
|
|
|
|
const PersonApiRepository(this._api);
|
|
|
|
Future<Person> update(String id, {String? name, DateTime? birthday}) async {
|
|
final birthdayUtc = birthday == null ? null : DateTime.utc(birthday.year, birthday.month, birthday.day);
|
|
final dto = PersonUpdateDto(
|
|
name: name == null ? const Optional.absent() : Optional.present(name),
|
|
birthDate: birthdayUtc == null ? const Optional.absent() : Optional.present(birthdayUtc),
|
|
);
|
|
final response = await checkNull(_api.updatePerson(id, dto));
|
|
return _toPerson(response);
|
|
}
|
|
|
|
static Person _toPerson(PersonResponseDto dto) =>
|
|
.new(birthDate: dto.birthDate, id: dto.id, name: dto.name, updatedAt: dto.updatedAt.orElse(null));
|
|
}
|