mirror of
https://github.com/immich-app/immich.git
synced 2025-08-11 09:16:31 -04:00
* chore: bump dart sdk to 3.8 * chore: make build * make pigeon * chore: format files --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
30 lines
1.0 KiB
Dart
30 lines
1.0 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:http/http.dart';
|
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/api.repository.dart';
|
|
import 'package:immich_mobile/infrastructure/utils/user.converter.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
class UserApiRepository extends ApiRepository {
|
|
final UsersApi _api;
|
|
const UserApiRepository(this._api);
|
|
|
|
Future<UserDto?> getMyUser() async {
|
|
final (adminDto, preferenceDto) = await (_api.getMyUser(), _api.getMyPreferences()).wait;
|
|
if (adminDto == null) return null;
|
|
|
|
return UserConverter.fromAdminDto(adminDto, preferenceDto);
|
|
}
|
|
|
|
Future<String> createProfileImage({required String name, required Uint8List data}) async {
|
|
final res = await checkNull(_api.createProfileImage(MultipartFile.fromBytes('file', data, filename: name)));
|
|
return res.profileImagePath;
|
|
}
|
|
|
|
Future<List<UserDto>> getAll() async {
|
|
final dto = await checkNull(_api.searchUsers());
|
|
return dto.map(UserConverter.fromSimpleUserDto).toList();
|
|
}
|
|
}
|