From 7655a978e8d76914075c89ebe4fd7a1533ca13da Mon Sep 17 00:00:00 2001 From: Gabby Gurdin Date: Mon, 4 Mar 2024 11:14:10 -0500 Subject: [PATCH] null check fix --- ios/Runner/Info.plist | 1 - lib/pages/chat/events/message.dart | 3 +- lib/pages/chat/events/message_content.dart | 2 +- lib/pangea/widgets/igc/pangea_rich_text.dart | 30 +++++++++++--------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 7243762696..8901572e95 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -86,7 +86,6 @@ UIBackgroundModes - audio fetch processing remote-notification diff --git a/lib/pages/chat/events/message.dart b/lib/pages/chat/events/message.dart index 3ddfe2c329..5b1a56cf5e 100644 --- a/lib/pages/chat/events/message.dart +++ b/lib/pages/chat/events/message.dart @@ -144,7 +144,8 @@ class Message extends StatelessWidget { final PangeaMessageEvent? pangeaMessageEvent = controller.getPangeaMessageEvent(event.eventId); ToolbarDisplayController? toolbarController; - if (event.messageType == MessageTypes.Text) { + if (event.messageType == MessageTypes.Text || + event.messageType == MessageTypes.Notice) { toolbarController = controller.getToolbarDisplayController(event.eventId); } // Pangea# diff --git a/lib/pages/chat/events/message_content.dart b/lib/pages/chat/events/message_content.dart index daa0a9a54d..9b930cf839 100644 --- a/lib/pages/chat/events/message_content.dart +++ b/lib/pages/chat/events/message_content.dart @@ -279,7 +279,7 @@ class MessageContent extends StatelessWidget { style: messageTextStyle, pangeaMessageEvent: pangeaMessageEvent!, immersionMode: immersionMode, - toolbarController: toolbarController!, + toolbarController: toolbarController, ); } // Pangea# diff --git a/lib/pangea/widgets/igc/pangea_rich_text.dart b/lib/pangea/widgets/igc/pangea_rich_text.dart index 0ceeb2110c..fb0fcef1ce 100644 --- a/lib/pangea/widgets/igc/pangea_rich_text.dart +++ b/lib/pangea/widgets/igc/pangea_rich_text.dart @@ -19,7 +19,7 @@ import '../../models/pangea_match_model.dart'; class PangeaRichText extends StatefulWidget { final PangeaMessageEvent pangeaMessageEvent; final bool immersionMode; - final ToolbarDisplayController toolbarController; + final ToolbarDisplayController? toolbarController; final TextStyle? style; const PangeaRichText({ @@ -89,7 +89,7 @@ class PangeaRichTextState extends State { .onError((error, stackTrace) => ErrorHandler.logError()) .then((event) { repEvent = event; - widget.toolbarController.toolbar?.textSelection.setMessageText( + widget.toolbarController?.toolbar?.textSelection.setMessageText( repEvent?.text ?? widget.pangeaMessageEvent.body, ); }).whenComplete(() { @@ -99,7 +99,7 @@ class PangeaRichTextState extends State { }); return widget.pangeaMessageEvent.body; } else { - widget.toolbarController.toolbar?.textSelection.setMessageText( + widget.toolbarController?.toolbar?.textSelection.setMessageText( repEvent!.text, ); setState(() {}); @@ -129,31 +129,33 @@ class PangeaRichTextState extends State { final Widget richText = SelectableText.rich( onSelectionChanged: (selection, cause) { if (cause == SelectionChangedCause.longPress && - !widget.toolbarController.highlighted && - !widget.toolbarController.controller.selectedEvents.any( - (e) => e.eventId == widget.pangeaMessageEvent.eventId, - )) { - widget.toolbarController.controller.onSelectMessage( + !(widget.toolbarController?.highlighted ?? false) && + !(widget.toolbarController?.controller.selectedEvents.any( + (e) => e.eventId == widget.pangeaMessageEvent.eventId, + ) ?? + false)) { + widget.toolbarController?.controller.onSelectMessage( widget.pangeaMessageEvent.event, ); return; } - widget.toolbarController.toolbar?.textSelection + widget.toolbarController?.toolbar?.textSelection .onTextSelection(selection); }, - onTap: () => widget.toolbarController.showToolbar(context), - enableInteractiveSelection: widget.toolbarController.highlighted, + onTap: () => widget.toolbarController?.showToolbar(context), + enableInteractiveSelection: + widget.toolbarController?.highlighted ?? false, contextMenuBuilder: (context, state) => - widget.toolbarController.highlighted + widget.toolbarController?.highlighted ?? true ? const SizedBox.shrink() : MessageContextMenu.contextMenuOverride( context: context, textSelection: state, - onDefine: () => widget.toolbarController.showToolbar( + onDefine: () => widget.toolbarController?.showToolbar( context, mode: MessageMode.definition, ), - onListen: () => widget.toolbarController.showToolbar( + onListen: () => widget.toolbarController?.showToolbar( context, mode: MessageMode.play, ),