From 910b8188ae74952dd1747dc3cb72bb162077960c Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 2 Nov 2019 09:18:15 +0100 Subject: [PATCH] Fix refresh issue when conversation has been closed --- lib/ui/screens/conversation_screen.dart | 43 +++++++++++++------------ 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/ui/screens/conversation_screen.dart b/lib/ui/screens/conversation_screen.dart index 7843eae..70caac4 100644 --- a/lib/ui/screens/conversation_screen.dart +++ b/lib/ui/screens/conversation_screen.dart @@ -64,8 +64,7 @@ class _ConversationScreenState extends State { void deactivate() { super.deactivate(); - if(_refreshTime != null) - _refreshTime.cancel(); + if (_refreshTime != null) _refreshTime.cancel(); } void _setError(ErrorLevel err) => setState(() => _error = err); @@ -94,6 +93,8 @@ class _ConversationScreenState extends State { /// Load a list of messages Future _loadMessages(bool online) async { + if (!mounted) return; + //First, get the messages final messages = await _conversationsHelper.getNewMessages( conversationID: widget.conversationID, @@ -417,27 +418,27 @@ class _ConversationScreenState extends State { final choice = await showDialog( context: context, builder: (c) => AlertDialog( - title: Text(tr("Confirm deletion")), - content: Text( - tr("Do you really want to delete this message ? The operation can not be cancelled !"), - textAlign: TextAlign.justify, + title: Text(tr("Confirm deletion")), + content: Text( + tr("Do you really want to delete this message ? The operation can not be cancelled !"), + textAlign: TextAlign.justify, + ), + actions: [ + FlatButton( + child: Text( + tr("Cancel").toUpperCase(), ), - actions: [ - FlatButton( - child: Text( - tr("Cancel").toUpperCase(), - ), - onPressed: () => Navigator.pop(c, false), - ), - FlatButton( - child: Text( - tr("Confirm").toUpperCase(), - style: TextStyle(color: Colors.red), - ), - onPressed: () => Navigator.pop(c, true), - ), - ], + onPressed: () => Navigator.pop(c, false), ), + FlatButton( + child: Text( + tr("Confirm").toUpperCase(), + style: TextStyle(color: Colors.red), + ), + onPressed: () => Navigator.pop(c, true), + ), + ], + ), ); if (choice == null || !choice) return;