minor fixes

This commit is contained in:
shenlong-tanwen 2026-08-12 20:14:44 +05:30
parent f2246b293c
commit dc9ce79c2d
3 changed files with 2 additions and 39 deletions

View file

@ -11,11 +11,6 @@ class PersonApiRepository extends ApiRepository {
PersonApiRepository(this._api);
Future<List<Person>> getAll() async {
final dto = await checkNull(_api.getAllPeople());
return dto.people.map(_toPerson).toList();
}
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(
@ -27,5 +22,5 @@ class PersonApiRepository extends ApiRepository {
}
static Person _toPerson(PersonResponseDto dto) =>
.new(birthDate: dto.birthDate, id: dto.id, name: dto.name, updatedAt: dto.updatedAt.value);
.new(birthDate: dto.birthDate, id: dto.id, name: dto.name, updatedAt: dto.updatedAt.orElse(null));
}

View file

@ -1,32 +0,0 @@
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/domain/models/person.model.dart';
import 'package:immich_mobile/repositories/person_api.repository.dart';
import 'package:logging/logging.dart';
final personServiceProvider = Provider.autoDispose<PersonService>(
(ref) => PersonService(ref.watch(personApiRepositoryProvider)),
);
class PersonService {
final Logger _log = Logger("PersonService");
final PersonApiRepository _personApiRepository;
PersonService(this._personApiRepository);
Future<List<Person>> getAllPeople() async {
try {
return await _personApiRepository.getAll();
} catch (error, stack) {
_log.severe("Error while fetching curated people", error, stack);
return [];
}
}
Future<Person?> updateName(String id, String name) async {
try {
return await _personApiRepository.update(id, name: name);
} catch (error, stack) {
_log.severe("Error while updating person name", error, stack);
}
return null;
}
}

View file

@ -65,7 +65,7 @@ class PeoplePicker extends HookConsumerWidget {
padding: const EdgeInsets.only(bottom: 2.0),
child: LargeLeadingTile(
title: Text(
person.name,
person.name.nullIfEmpty ?? context.t.no_name,
style: context.textTheme.bodyLarge?.copyWith(
fontSize: 20,
fontWeight: FontWeight.w500,