mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 16:41:59 +00:00
202082f62e
* UserService * PartnerService * HashService * MemoryService * PersonService * SearchService * StackService
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:http/http.dart';
|
|
import 'package:immich_mobile/entities/user.entity.dart';
|
|
import 'package:immich_mobile/interfaces/user_api.interface.dart';
|
|
import 'package:immich_mobile/providers/api.provider.dart';
|
|
import 'package:immich_mobile/repositories/base_api.repository.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final userApiRepositoryProvider = Provider(
|
|
(ref) => UserApiRepository(
|
|
ref.watch(apiServiceProvider).usersApi,
|
|
),
|
|
);
|
|
|
|
class UserApiRepository extends BaseApiRepository
|
|
implements IUserApiRepository {
|
|
final UsersApi _api;
|
|
|
|
UserApiRepository(this._api);
|
|
|
|
@override
|
|
Future<List<User>> getAll() async {
|
|
final dto = await checkNull(_api.searchUsers());
|
|
return dto.map(User.fromSimpleUserDto).toList();
|
|
}
|
|
|
|
@override
|
|
Future<({String profileImagePath})> createProfileImage({
|
|
required String name,
|
|
required Uint8List data,
|
|
}) async {
|
|
final response = await checkNull(
|
|
_api.createProfileImage(
|
|
MultipartFile.fromBytes('file', data, filename: name),
|
|
),
|
|
);
|
|
return (profileImagePath: response.profileImagePath);
|
|
}
|
|
}
|