You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-07-03 05:46:58 +02:00
Refactor mobile to use OpenApi generated SDK (#336)
This commit is contained in:
@ -1,29 +1,22 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:immich_mobile/shared/models/mapbox_info.model.dart';
|
||||
import 'package:immich_mobile/shared/models/server_version.model.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class ServerInfoState {
|
||||
final MapboxInfo mapboxInfo;
|
||||
final ServerVersion serverVersion;
|
||||
final ServerVersionReponseDto serverVersion;
|
||||
final bool isVersionMismatch;
|
||||
final String versionMismatchErrorMessage;
|
||||
|
||||
ServerInfoState({
|
||||
required this.mapboxInfo,
|
||||
required this.serverVersion,
|
||||
required this.isVersionMismatch,
|
||||
required this.versionMismatchErrorMessage,
|
||||
});
|
||||
|
||||
ServerInfoState copyWith({
|
||||
MapboxInfo? mapboxInfo,
|
||||
ServerVersion? serverVersion,
|
||||
ServerVersionReponseDto? serverVersion,
|
||||
bool? isVersionMismatch,
|
||||
String? versionMismatchErrorMessage,
|
||||
}) {
|
||||
return ServerInfoState(
|
||||
mapboxInfo: mapboxInfo ?? this.mapboxInfo,
|
||||
serverVersion: serverVersion ?? this.serverVersion,
|
||||
isVersionMismatch: isVersionMismatch ?? this.isVersionMismatch,
|
||||
versionMismatchErrorMessage:
|
||||
@ -31,32 +24,9 @@ class ServerInfoState {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'mapboxInfo': mapboxInfo.toMap(),
|
||||
'serverVersion': serverVersion.toMap(),
|
||||
'isVersionMismatch': isVersionMismatch,
|
||||
'versionMismatchErrorMessage': versionMismatchErrorMessage,
|
||||
};
|
||||
}
|
||||
|
||||
factory ServerInfoState.fromMap(Map<String, dynamic> map) {
|
||||
return ServerInfoState(
|
||||
mapboxInfo: MapboxInfo.fromMap(map['mapboxInfo']),
|
||||
serverVersion: ServerVersion.fromMap(map['serverVersion']),
|
||||
isVersionMismatch: map['isVersionMismatch'] ?? false,
|
||||
versionMismatchErrorMessage: map['versionMismatchErrorMessage'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ServerInfoState.fromJson(String source) =>
|
||||
ServerInfoState.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerInfoState(mapboxInfo: $mapboxInfo, serverVersion: $serverVersion, isVersionMismatch: $isVersionMismatch, versionMismatchErrorMessage: $versionMismatchErrorMessage)';
|
||||
return 'ServerInfoState( serverVersion: $serverVersion, isVersionMismatch: $isVersionMismatch, versionMismatchErrorMessage: $versionMismatchErrorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -64,7 +34,6 @@ class ServerInfoState {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ServerInfoState &&
|
||||
other.mapboxInfo == mapboxInfo &&
|
||||
other.serverVersion == serverVersion &&
|
||||
other.isVersionMismatch == isVersionMismatch &&
|
||||
other.versionMismatchErrorMessage == versionMismatchErrorMessage;
|
||||
@ -72,8 +41,7 @@ class ServerInfoState {
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return mapboxInfo.hashCode ^
|
||||
serverVersion.hashCode ^
|
||||
return serverVersion.hashCode ^
|
||||
isVersionMismatch.hashCode ^
|
||||
versionMismatchErrorMessage.hashCode;
|
||||
}
|
||||
|
Reference in New Issue
Block a user