From 1a1416e44668392576d4e9fc866f672ad986542d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 13 Apr 2021 23:13:29 +0200 Subject: [PATCH] change chat names correctly on contact name change the user-given contact name may be set to an empty string; in this case the authname or the email is used for the contact and also for the name of possibly existing chats. this works well for `dc_chat_get_name()` as that just uses `dc_contact_get_display_name()` for single-chats. it did not work for `dc_get_chatlist(query)` as that uses the database for performance reasons - however, in the database, the empty string is written instead of the display name is written for a chat. this is fixed by this pr by also using dc_contact_get_display_name() when updating the chats-table (similar to `dc_create_chat_by_contact_id()`) --- src/contact.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/contact.rs b/src/contact.rs index 4fb97e311..2f9cf9241 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -501,13 +501,15 @@ impl Contact { ).bind(Chattype::Single).bind(row_id) ).await?; if let Some(chat_id) = chat_id { + let contact = Contact::get_by_id(context, row_id as u32).await?; + let chat_name = contact.get_display_name(); match context .sql .execute( sqlx::query("UPDATE chats SET name=?1 WHERE id=?2 AND name!=?3") - .bind(&new_name) + .bind(&chat_name) .bind(chat_id) - .bind(&new_name), + .bind(&chat_name), ) .await {