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