diff --git a/src/chat.rs b/src/chat.rs index 9d36f30d8..883ba39b0 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -3921,6 +3921,11 @@ pub async fn remove_contact_from_chat( let mut msg = Message::default(); let chat = Chat::load_from_db(context, chat_id).await?; + + if chat.typ == Chattype::Group && contact_id == ContactId::SELF { + chat_id.set_draft(context, None).await?; // Clear draft since the user left the group. + } + if chat.typ == Chattype::Group || chat.typ == Chattype::Broadcast { if !chat.is_self_in_chat(context).await? { let err_msg = format!( @@ -4611,6 +4616,11 @@ async fn set_contacts_by_addrs(context: &Context, id: ChatId, addrs: &[String]) if contacts == contacts_old { return Ok(()); } + + if chat.typ == Chattype::Group && !contacts.contains(&ContactId::SELF) { + id.set_draft(context, None).await?; // Clear draft since the user left the group. + } + update_chat_contacts_table(context, id, &contacts).await?; context.emit_event(EventType::ChatModified(id)); Ok(()) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index f3d513a60..3774b5f65 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2317,6 +2317,9 @@ async fn apply_group_changes( } if new_members != chat_contacts { + if !new_members.contains(&ContactId::SELF) { + chat_id.set_draft(context, None).await?; // Clear draft since Self was removed from the group. + } chat::update_chat_contacts_table(context, chat_id, &new_members).await?; chat_contacts = new_members; send_event_chat_modified = true;