1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-30 11:28:22 +02:00
immich/mobile/lib/modules/search/services/person.service.dart
martin f28fc8fa5c
feat(server,web): hide faces (#3262)
* feat: hide faces

* fix: types

* pr feedback

* fix: svelte checks

* feat: new server endpoint

* refactor: rename person count dto

* fix(server): linter

* fix: remove duplicate button

* docs: add comments

* pr feedback

* fix: get unhidden faces

* fix: do not use PersonCountResponseDto

* fix: transition

* pr feedback

* pr feedback

* fix: remove unused check

* add server tests

* rename persons to people

* feat: add exit button

* pr feedback

* add server tests

* pr feedback

* pr feedback

* fix: show & hide faces

* simplify

* fix: close button

* pr feeback

* pr feeback

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-07-18 13:09:43 -05:00

58 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/providers/api.provider.dart';
import 'package:immich_mobile/shared/services/api.service.dart';
import 'package:openapi/api.dart';
final personServiceProvider = Provider(
(ref) => PersonService(
ref.watch(apiServiceProvider),
),
);
class PersonService {
final ApiService _apiService;
PersonService(this._apiService);
Future<List<PersonResponseDto>?> getCuratedPeople() async {
try {
final peopleResponseDto = await _apiService.personApi.getAllPeople();
return peopleResponseDto?.people;
} catch (e) {
debugPrint("Error [getCuratedPeople] ${e.toString()}");
return null;
}
}
Future<List<Asset>?> getPersonAssets(String id) async {
try {
final assets = await _apiService.personApi.getPersonAssets(id);
if (assets == null) {
return null;
}
return assets.map((e) => Asset.remote(e)).toList();
} catch (e) {
debugPrint("Error [getPersonAssets] ${e.toString()}");
return null;
}
}
Future<PersonResponseDto?> updateName(String id, String name) async {
try {
return await _apiService.personApi.updatePerson(
id,
PersonUpdateDto(
name: name,
),
);
} catch (e) {
debugPrint("Error [updateName] ${e.toString()}");
return null;
}
}
}