1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 22:39:22 +00:00

Handle conversation deleted event

This commit is contained in:
Pierre HUBERT 2021-03-13 13:52:18 +01:00
parent f9db9aa632
commit fb80f3bd52
3 changed files with 22 additions and 4 deletions

View File

@ -80,11 +80,18 @@ class DeletedConversationMessageEvent {
}
/// Remove user from conversation
class RemovedUserFromConversation {
class RemovedUserFromConversationEvent {
final int convID;
final int userID;
RemovedUserFromConversation(this.convID, this.userID);
RemovedUserFromConversationEvent(this.convID, this.userID);
}
/// Deleted conversation
class DeletedConversationEvent {
final int convID;
DeletedConversationEvent(this.convID);
}
/// User joined call event

View File

@ -170,10 +170,15 @@ class WebSocketHelper {
// Removed user from conversation
case "removed_user_from_conv":
EventsHelper.emit(RemovedUserFromConversation(
EventsHelper.emit(RemovedUserFromConversationEvent(
msg.data["conv_id"], msg.data["user_id"]));
break;
// Conversation deleted
case "deleted_conversation":
EventsHelper.emit(DeletedConversationEvent(msg.data));
break;
// A user joined a call
case "user_joined_call":
EventsHelper.emit(

View File

@ -186,11 +186,17 @@ class _ConversationScreenState extends SafeState<ConversationScreen> {
}
});
this.listen<RemovedUserFromConversation>((ev) {
this.listen<RemovedUserFromConversationEvent>((ev) {
if (ev.userID == userID() && ev.convID == widget.conversationID) {
setState(() => _error = ErrorLevel.MAJOR);
}
});
this.listen<DeletedConversationEvent>((ev) {
if (ev.convID == widget.conversationID) {
setState(() => _error = ErrorLevel.MAJOR);
}
});
}
/// Free resources when this conversation widget is no longer required