From a630a5ae79303aea35b7ab06d12778cd3fe5cba4 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 13 Mar 2021 12:16:57 +0100 Subject: [PATCH] Handle user removed from conversation events --- lib/helpers/events_helper.dart | 8 ++++++++ lib/helpers/websocket_helper.dart | 6 ++++++ lib/ui/screens/conversation_screen.dart | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/lib/helpers/events_helper.dart b/lib/helpers/events_helper.dart index 86aec6a..8c41b8e 100644 --- a/lib/helpers/events_helper.dart +++ b/lib/helpers/events_helper.dart @@ -79,6 +79,14 @@ class DeletedConversationMessageEvent { DeletedConversationMessageEvent(this.msg); } +/// Remove user from conversation +class RemovedUserFromConversation { + final int convID; + final int userID; + + RemovedUserFromConversation(this.convID, this.userID); +} + /// User joined call event class UserJoinedCallEvent { final int callID; diff --git a/lib/helpers/websocket_helper.dart b/lib/helpers/websocket_helper.dart index d0c7453..c218276 100644 --- a/lib/helpers/websocket_helper.dart +++ b/lib/helpers/websocket_helper.dart @@ -168,6 +168,12 @@ class WebSocketHelper { ConversationsHelper.apiToConversationMessage(msg.data))); break; + // Removed user from conversation + case "removed_user_from_conv": + EventsHelper.emit(RemovedUserFromConversation( + msg.data["conv_id"], msg.data["user_id"])); + break; + // A user joined a call case "user_joined_call": EventsHelper.emit( diff --git a/lib/ui/screens/conversation_screen.dart b/lib/ui/screens/conversation_screen.dart index 673f1e6..9dc0976 100644 --- a/lib/ui/screens/conversation_screen.dart +++ b/lib/ui/screens/conversation_screen.dart @@ -18,6 +18,7 @@ import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/ui/widgets/scroll_watcher.dart'; import 'package:comunic/ui/widgets/user_writing_in_conv_notifier.dart'; +import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/date_utils.dart'; import 'package:comunic/utils/files_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -184,6 +185,12 @@ class _ConversationScreenState extends SafeState { setState(() => _messages.removeMsg(ev.msg.id)); } }); + + this.listen((ev) { + if (ev.userID == userID() && ev.convID == widget.conversationID) { + setState(() => _error = ErrorLevel.MAJOR); + } + }); } /// Free resources when this conversation widget is no longer required