Change ID process and equality checking for Credentials and Profiles

codemagic-setup
Hank Grabowski 2023-02-27 14:53:16 -05:00
rodzic a6bf00aea4
commit 7c68ee62a4
2 zmienionych plików z 19 dodań i 8 usunięć

Wyświetl plik

@ -72,4 +72,14 @@ class BasicCredentials extends ICredentials {
'password': password,
'serverName': serverName,
};
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BasicCredentials &&
runtimeType == other.runtimeType &&
id == other.id;
@override
int get hashCode => id.hashCode;
}

Wyświetl plik

@ -1,5 +1,3 @@
import 'package:uuid/uuid.dart';
import 'credentials_intf.dart';
class Profile {
@ -8,20 +6,21 @@ class Profile {
final String userId;
final String avatar;
final String serverName;
final String id;
final bool loggedIn;
String get handle => '$username@$serverName';
String get id =>
'${credentials.runtimeType.toString()}-$userId-$username-$serverName';
Profile({
String? id,
required this.credentials,
required this.username,
required this.userId,
required this.avatar,
required this.serverName,
required this.loggedIn,
}) : id = id ?? const Uuid().v4();
});
factory Profile.credentialsOnly(ICredentials credentials) => Profile(
credentials: credentials,
@ -44,7 +43,6 @@ class Profile {
avatar: json['avatar'],
serverName: json['serverName'],
loggedIn: json['loggedIn'],
id: json['id'],
);
}
@ -54,7 +52,6 @@ class Profile {
userId: userId,
avatar: avatar,
serverName: serverName,
id: id,
loggedIn: status,
);
@ -65,7 +62,6 @@ class Profile {
'avatar': avatar,
'serverName': serverName,
'loggedIn': loggedIn,
'id': id,
};
@override
@ -75,4 +71,9 @@ class Profile {
@override
int get hashCode => id.hashCode;
@override
String toString() {
return 'Profile{logged_in: $loggedIn, handle: $handle, credentials_id: $id}';
}
}