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()`)
This commit is contained in:
B. Petersen
2021-04-13 23:13:29 +02:00
committed by bjoern
parent 0afc07f6e7
commit 1a1416e446

View File

@@ -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
{