diff --git a/CHANGELOG.md b/CHANGELOG.md index 44dba5908..fa97e420f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Removed DC_STR_NEWGROUPDRAFT, we don't set draft after creating group anymore #2805 + ## 1.65.0 ### Changes diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 1eb500e33..dc84e8642 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -5613,12 +5613,6 @@ void dc_event_unref(dc_event_t* event); /// if nothing else is set by the dc_set_config()-option `selfstatus`. #define DC_STR_STATUSLINE 13 -/// "Hi, i've created the group %1$s for us." -/// -/// Used as a draft text after group creation. -/// - %1$s will be replaced by the group name -#define DC_STR_NEWGROUPDRAFT 14 - /// "Group name changed from %1$s to %2$s." /// /// Used in status messages for group name changes. diff --git a/python/tests/test_account.py b/python/tests/test_account.py index e409e73a9..100ba0fd3 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -265,23 +265,23 @@ class TestOfflineChat: assert d["draft"] == "" if chat.get_draft() is None else chat.get_draft() def test_group_chat_creation_with_translation(self, ac1): - ac1.set_stock_translation(const.DC_STR_NEWGROUPDRAFT, "xyz %1$s") + ac1.set_stock_translation(const.DC_STR_MSGGRPNAME, "abc %1$s xyz %2$s") ac1._evtracker.consume_events() with pytest.raises(ValueError): - ac1.set_stock_translation(const.DC_STR_NEWGROUPDRAFT, "xyz %2$s") + ac1.set_stock_translation(const.DC_STR_FILE, "xyz %1$s") + ac1._evtracker.get_matching("DC_EVENT_WARNING") + with pytest.raises(ValueError): + ac1.set_stock_translation(const.DC_STR_CONTACT_NOT_VERIFIED, "xyz %2$s") ac1._evtracker.get_matching("DC_EVENT_WARNING") with pytest.raises(ValueError): ac1.set_stock_translation(500, "xyz %1$s") ac1._evtracker.get_matching("DC_EVENT_WARNING") - contact1 = ac1.create_contact("some1@example.org", name="some1") - contact2 = ac1.create_contact("some2@example.org", name="some2") - chat = ac1.create_group_chat(name="title1", contacts=[contact1, contact2]) - assert chat.get_name() == "title1" - assert contact1 in chat.get_contacts() - assert contact2 in chat.get_contacts() - assert not chat.is_promoted() - msg = chat.get_draft() - assert msg.text == "xyz title1" + chat = ac1.create_group_chat(name="homework", contacts=[]) + assert chat.get_name() == "homework" + chat.send_text("Now we have a group for homework") + assert chat.is_promoted() + chat.set_name("Homework") + assert chat.get_messages()[-1].text == "abc homework xyz Homework by me." @pytest.mark.parametrize("verified", [True, False]) def test_group_chat_qr(self, acfactory, ac1, verified): diff --git a/src/chat.rs b/src/chat.rs index ce34ceef0..5eeb6e770 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2267,7 +2267,6 @@ pub async fn create_group_chat( let chat_name = improve_single_line_input(chat_name); ensure!(!chat_name.is_empty(), "Invalid chat name"); - let draft_txt = stock_str::new_group_draft(context, &chat_name).await; let grpid = dc_create_id(); let row_id = context @@ -2288,9 +2287,6 @@ pub async fn create_group_chat( let chat_id = ChatId::new(u32::try_from(row_id)?); if !is_contact_in_chat(context, chat_id, DC_CONTACT_ID_SELF).await? { add_to_chat_contacts_table(context, chat_id, DC_CONTACT_ID_SELF).await?; - let mut draft_msg = Message::new(Viewtype::Text); - draft_msg.set_text(Some(draft_txt)); - chat_id.set_draft_raw(context, &mut draft_msg).await?; } context.emit_event(EventType::MsgsChanged { diff --git a/src/chatlist.rs b/src/chatlist.rs index 60a3575e3..2009bc5f7 100644 --- a/src/chatlist.rs +++ b/src/chatlist.rs @@ -399,10 +399,20 @@ mod tests { assert_eq!(chats.get_chat_id(1), chat_id2); assert_eq!(chats.get_chat_id(2), chat_id1); - // drafts are sorted to the top - let mut msg = Message::new(Viewtype::Text); - msg.set_text(Some("hello".to_string())); - chat_id2.set_draft(&t, Some(&mut msg)).await.unwrap(); + // New drafts are sorted to the top + // We have to set a draft on the other two messages, too, as + // chat timestamps are only exact to the second and sorting by timestamp + // would not work. + // Message timestamps are "smeared" and unique, so we don't have this problem + // if we have any message (can be a draft) in all chats. + // Instead of setting drafts for chat_id1 and chat_id3, we could also sleep + // 2s here. + for chat_id in &[chat_id1, chat_id3, chat_id2] { + let mut msg = Message::new(Viewtype::Text); + msg.set_text(Some("hello".to_string())); + chat_id.set_draft(&t, Some(&mut msg)).await.unwrap(); + } + let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap(); assert_eq!(chats.get_chat_id(0), chat_id2); diff --git a/src/stock_str.rs b/src/stock_str.rs index 8e5da95ef..91fcee64a 100644 --- a/src/stock_str.rs +++ b/src/stock_str.rs @@ -56,9 +56,6 @@ pub enum StockMessage { #[strum(props(fallback = "Sent with my Delta Chat Messenger: https://delta.chat"))] StatusLine = 13, - #[strum(props(fallback = "Hello, I\'ve just created the group \"%1$s\" for us."))] - NewGroupDraft = 14, - #[strum(props(fallback = "Group name changed from \"%1$s\" to \"%2$s\"."))] MsgGrpName = 15, @@ -457,13 +454,6 @@ pub(crate) async fn status_line(context: &Context) -> String { translated(context, StockMessage::StatusLine).await } -/// Stock string: `Hello, I've just created the group "%1$s" for us.`. -pub(crate) async fn new_group_draft(context: &Context, group_name: impl AsRef) -> String { - translated(context, StockMessage::NewGroupDraft) - .await - .replace1(group_name) -} - /// Stock string: `Group name changed from "%1$s" to "%2$s".`. pub(crate) async fn msg_grp_name( context: &Context,