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