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