fix: handle login

This commit is contained in:
shenlong-tanwen
2024-08-25 10:38:24 +05:30
parent 7f83740b35
commit 877c3b028b
27 changed files with 430 additions and 355 deletions
@@ -1,9 +1,10 @@
import 'package:immich_mobile/domain/models/user.model.dart';
import 'package:immich_mobile/utils/immich_api_client.dart';
import 'package:immich_mobile/utils/mixins/log_context.mixin.dart';
import 'package:openapi/openapi.dart';
import 'package:openapi/api.dart';
class UserService with LogContext {
final Openapi _api;
final ImmichApiClient _api;
UsersApi get _userApi => _api.getUsersApi();
@@ -11,15 +12,14 @@ class UserService with LogContext {
Future<User?> getMyUser() async {
try {
final response = await _userApi.getMyUser();
final dto = response.data;
if (dto == null) {
final userDto = await _userApi.getMyUser();
if (userDto == null) {
log.severe("Cannot fetch my user.");
return null;
}
final preferences = await _userApi.getMyPreferences();
return User.fromAdminDto(dto, preferences.data);
final preferencesDto = await _userApi.getMyPreferences();
return User.fromAdminDto(userDto, preferencesDto);
} catch (e, s) {
log.severe("Error while fetching server features", e, s);
}