fix: handle login
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user