mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
Refactor mobile to use OpenApi generated SDK (#336)
This commit is contained in:
parent
d69470e207
commit
ae7e582ec8
276 changed files with 14513 additions and 3003 deletions
|
|
@ -1,10 +1,8 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:immich_mobile/shared/models/device_info.model.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class AuthenticationState {
|
||||
final String deviceId;
|
||||
final String deviceType;
|
||||
final DeviceTypeEnum deviceType;
|
||||
final String userId;
|
||||
final String userEmail;
|
||||
final bool isAuthenticated;
|
||||
|
|
@ -13,8 +11,7 @@ class AuthenticationState {
|
|||
final bool isAdmin;
|
||||
final bool shouldChangePassword;
|
||||
final String profileImagePath;
|
||||
final DeviceInfoRemote deviceInfo;
|
||||
|
||||
final DeviceInfoResponseDto deviceInfo;
|
||||
AuthenticationState({
|
||||
required this.deviceId,
|
||||
required this.deviceType,
|
||||
|
|
@ -31,7 +28,7 @@ class AuthenticationState {
|
|||
|
||||
AuthenticationState copyWith({
|
||||
String? deviceId,
|
||||
String? deviceType,
|
||||
DeviceTypeEnum? deviceType,
|
||||
String? userId,
|
||||
String? userEmail,
|
||||
bool? isAuthenticated,
|
||||
|
|
@ -40,7 +37,7 @@ class AuthenticationState {
|
|||
bool? isAdmin,
|
||||
bool? shouldChangePassword,
|
||||
String? profileImagePath,
|
||||
DeviceInfoRemote? deviceInfo,
|
||||
DeviceInfoResponseDto? deviceInfo,
|
||||
}) {
|
||||
return AuthenticationState(
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
|
|
@ -57,45 +54,6 @@ class AuthenticationState {
|
|||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final result = <String, dynamic>{};
|
||||
|
||||
result.addAll({'deviceId': deviceId});
|
||||
result.addAll({'deviceType': deviceType});
|
||||
result.addAll({'userId': userId});
|
||||
result.addAll({'userEmail': userEmail});
|
||||
result.addAll({'isAuthenticated': isAuthenticated});
|
||||
result.addAll({'firstName': firstName});
|
||||
result.addAll({'lastName': lastName});
|
||||
result.addAll({'isAdmin': isAdmin});
|
||||
result.addAll({'shouldChangePassword': shouldChangePassword});
|
||||
result.addAll({'profileImagePath': profileImagePath});
|
||||
result.addAll({'deviceInfo': deviceInfo.toMap()});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
factory AuthenticationState.fromMap(Map<String, dynamic> map) {
|
||||
return AuthenticationState(
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
deviceType: map['deviceType'] ?? '',
|
||||
userId: map['userId'] ?? '',
|
||||
userEmail: map['userEmail'] ?? '',
|
||||
isAuthenticated: map['isAuthenticated'] ?? false,
|
||||
firstName: map['firstName'] ?? '',
|
||||
lastName: map['lastName'] ?? '',
|
||||
isAdmin: map['isAdmin'] ?? false,
|
||||
shouldChangePassword: map['shouldChangePassword'] ?? false,
|
||||
profileImagePath: map['profileImagePath'] ?? '',
|
||||
deviceInfo: DeviceInfoRemote.fromMap(map['deviceInfo']),
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory AuthenticationState.fromJson(String source) =>
|
||||
AuthenticationState.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthenticationState(deviceId: $deviceId, deviceType: $deviceType, userId: $userId, userEmail: $userEmail, isAuthenticated: $isAuthenticated, firstName: $firstName, lastName: $lastName, isAdmin: $isAdmin, shouldChangePassword: $shouldChangePassword, profileImagePath: $profileImagePath, deviceInfo: $deviceInfo)';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue