have Matrix.getBundles() use client instead of clientIndex

This commit is contained in:
Sorunome 2021-09-18 15:51:07 +02:00
parent 7c40f72f55
commit a973f8d371
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C

View File

@ -77,8 +77,8 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
return activeClient;
}
Map<String, List<int>> getBundles() {
final resBundles = <String, List<_AccountBundleWithClientIndex>>{};
Map<String, List<Client>> getBundles() {
final resBundles = <String, List<_AccountBundleWithClient>>{};
for (var i = 0; i < widget.clients.length; i++) {
final bundles = widget.clients[i].accountBundles;
for (final bundle in bundles) {
@ -86,8 +86,8 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
continue;
}
resBundles[bundle.name] ??= [];
resBundles[bundle.name].add(_AccountBundleWithClientIndex(
index: i,
resBundles[bundle.name].add(_AccountBundleWithClient(
client: widget.clients[i],
bundle: bundle,
));
}
@ -100,7 +100,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
: a.bundle.priority.compareTo(b.bundle.priority));
}
return resBundles
.map((k, v) => MapEntry(k, v.map((vv) => vv.index).toList()));
.map((k, v) => MapEntry(k, v.map((vv) => vv.client).toList()));
}
bool get hasComplexBundles => getBundles().values.any((v) => v.length > 1);
@ -597,8 +597,8 @@ class FixedThreepidCreds extends ThreepidCreds {
}
}
class _AccountBundleWithClientIndex {
final int index;
class _AccountBundleWithClient {
final Client client;
final AccountBundle bundle;
_AccountBundleWithClientIndex({this.index, this.bundle});
_AccountBundleWithClient({this.client, this.bundle});
}