|
|
|
@ -30,7 +30,7 @@ class Account implements Credentials {
|
|
|
|
|
required this.username, |
|
|
|
|
this.password, |
|
|
|
|
this.userAgent, |
|
|
|
|
}) : _client = NextcloudClient( |
|
|
|
|
}) : client = NextcloudClient( |
|
|
|
|
serverURL, |
|
|
|
|
loginName: username, |
|
|
|
|
password: password, |
|
|
|
@ -60,20 +60,10 @@ class Account implements Credentials {
|
|
|
|
|
@override |
|
|
|
|
int get hashCode => serverURL.hashCode + username.hashCode; |
|
|
|
|
|
|
|
|
|
String get id => client.id; |
|
|
|
|
final NextcloudClient client; |
|
|
|
|
|
|
|
|
|
String get humanReadableID => client.humanReadableID; |
|
|
|
|
|
|
|
|
|
final NextcloudClient _client; |
|
|
|
|
|
|
|
|
|
NextcloudClient get client => _client; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, String> _idCache = {}; |
|
|
|
|
|
|
|
|
|
extension NextcloudClientHelpers on NextcloudClient { |
|
|
|
|
String get id { |
|
|
|
|
final key = '$username@$baseURL'; |
|
|
|
|
final key = '$username@$serverURL'; |
|
|
|
|
if (_idCache[key] != null) { |
|
|
|
|
return _idCache[key]!; |
|
|
|
|
} |
|
|
|
@ -81,12 +71,14 @@ extension NextcloudClientHelpers on NextcloudClient {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String get humanReadableID { |
|
|
|
|
final uri = Uri.parse(baseURL); |
|
|
|
|
final uri = Uri.parse(serverURL); |
|
|
|
|
// Maybe also show path if it is not '/' ? |
|
|
|
|
return '${username!}@${uri.port != 443 ? '${uri.host}:${uri.port}' : uri.host}'; |
|
|
|
|
return '$username@${uri.port != 443 ? '${uri.host}:${uri.port}' : uri.host}'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String, String> _idCache = {}; |
|
|
|
|
|
|
|
|
|
extension AccountFind on Iterable<Account> { |
|
|
|
|
Account? tryFind(final String? accountID) => firstWhereOrNull((final account) => account.id == accountID); |
|
|
|
|
Account find(final String accountID) => firstWhere((final account) => account.id == accountID); |
|
|
|
|