mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-05 19:49:29 +01:00
refactor: Use correct Matrix instance
This commit is contained in:
parent
f1a8716832
commit
507cd1f17e
@ -51,8 +51,6 @@ class ChatController extends State<Chat> {
|
||||
|
||||
Timeline? timeline;
|
||||
|
||||
MatrixState? matrix;
|
||||
|
||||
String? readMarkerEventId;
|
||||
|
||||
String? get roomId => context.vRouter.pathParameters['roomid'];
|
||||
@ -694,14 +692,14 @@ class ChatController extends State<Chat> {
|
||||
}
|
||||
|
||||
List<Client?> get currentRoomBundle {
|
||||
final clients = matrix!.currentBundle!;
|
||||
final clients = Matrix.of(context).currentBundle!;
|
||||
clients.removeWhere((c) => c!.getRoomById(roomId!) == null);
|
||||
return clients;
|
||||
}
|
||||
|
||||
bool get canRedactSelectedEvents {
|
||||
if (isArchived) return false;
|
||||
final clients = matrix!.currentBundle;
|
||||
final clients = Matrix.of(context).currentBundle;
|
||||
for (final event in selectedEvents) {
|
||||
if (event.canRedact == false &&
|
||||
!(clients!.any((cl) => event.senderId == cl!.userID))) return false;
|
||||
@ -1039,7 +1037,7 @@ class ChatController extends State<Chat> {
|
||||
await prefs.setString('draft_$roomId', text);
|
||||
});
|
||||
setReadMarker();
|
||||
if (text.endsWith(' ') && matrix!.hasComplexBundles) {
|
||||
if (text.endsWith(' ') && Matrix.of(context).hasComplexBundles) {
|
||||
final clients = currentRoomBundle;
|
||||
for (final client in clients) {
|
||||
final prefix = client!.sendPrefix;
|
||||
|
@ -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,
|
||||
),
|
||||
),
|
||||
|
@ -139,8 +139,7 @@ class ChatView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
controller.matrix ??= Matrix.of(context);
|
||||
final client = controller.matrix!.client;
|
||||
final client = Matrix.of(context).client;
|
||||
controller.sendingClient ??= client;
|
||||
controller.room = controller.sendingClient!.getRoomById(controller.roomId!);
|
||||
controller.readMarkerEventId ??= controller.room!.fullyRead;
|
||||
|
Loading…
Reference in New Issue
Block a user