refactor: Use correct Matrix instance
This commit is contained in:
parent
ecb2f0fe52
commit
af71649da6
3 changed files with 12 additions and 15 deletions
|
|
@ -215,9 +215,9 @@ class ChatInputRow extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (controller.matrix!.isMultiAccount &&
|
||||
controller.matrix!.hasComplexBundles &&
|
||||
controller.matrix!.currentBundle!.length > 1)
|
||||
if (Matrix.of(context).isMultiAccount &&
|
||||
Matrix.of(context).hasComplexBundles &&
|
||||
Matrix.of(context).currentBundle!.length > 1)
|
||||
Container(
|
||||
height: 56,
|
||||
alignment: Alignment.center,
|
||||
|
|
@ -279,8 +279,9 @@ class _ChatAccountPicker extends StatelessWidget {
|
|||
|
||||
const _ChatAccountPicker(this.controller, {Key? key}) : super(key: key);
|
||||
|
||||
void _popupMenuButtonSelected(String mxid) {
|
||||
final client = controller.matrix!.currentBundle!
|
||||
void _popupMenuButtonSelected(String mxid, BuildContext context) {
|
||||
final client = Matrix.of(context)
|
||||
.currentBundle!
|
||||
.firstWhere((cl) => cl!.userID == mxid, orElse: () => null);
|
||||
if (client == null) {
|
||||
Logs().w('Attempted to switch to a non-existing client $mxid');
|
||||
|
|
@ -291,14 +292,13 @@ class _ChatAccountPicker extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
controller.matrix ??= Matrix.of(context);
|
||||
final clients = controller.currentRoomBundle;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: FutureBuilder<Profile>(
|
||||
future: controller.sendingClient!.fetchOwnProfile(),
|
||||
builder: (context, snapshot) => PopupMenuButton<String>(
|
||||
onSelected: _popupMenuButtonSelected,
|
||||
onSelected: (mxid) => _popupMenuButtonSelected(mxid, context),
|
||||
itemBuilder: (BuildContext context) => clients
|
||||
.map(
|
||||
(client) => PopupMenuItem<String>(
|
||||
|
|
@ -322,7 +322,7 @@ class _ChatAccountPicker extends StatelessWidget {
|
|||
child: Avatar(
|
||||
mxContent: snapshot.data?.avatarUrl,
|
||||
name: snapshot.data?.displayName ??
|
||||
controller.matrix!.client.userID!.localpart,
|
||||
Matrix.of(context).client.userID!.localpart,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue