mirror of
https://github.com/immich-app/immich.git
synced 2024-11-24 08:52:28 +02:00
15c04d3056
* refactor(mobile): DB repository for asset, backup, sync service * review feedback * fix bug found by Alex --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
41 lines
1.1 KiB
Dart
41 lines
1.1 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/api.repository.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final userApiRepositoryProvider = Provider(
|
|
(ref) => UserApiRepository(
|
|
ref.watch(apiServiceProvider).usersApi,
|
|
),
|
|
);
|
|
|
|
class UserApiRepository extends ApiRepository 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);
|
|
}
|
|
}
|