fix searching for localized device chats

This commit is contained in:
B. Petersen
2019-12-26 11:55:37 +01:00
committed by Alexander Krotov
parent 6702ef4a71
commit cb2a1147f0
2 changed files with 26 additions and 0 deletions

View File

@@ -720,6 +720,28 @@ pub fn update_device_icon(context: &Context) -> Result<(), Error> {
Ok(())
}
fn update_special_chat_name(
context: &Context,
contact_id: u32,
stock_id: StockMessage,
) -> Result<(), Error> {
if let Ok((chat_id, _)) = lookup_by_contact_id(context, contact_id) {
let name: String = context.stock_str(stock_id).into();
// the `!= name` condition avoids unneeded writes
context.sql.execute(
"UPDATE chats SET name=? WHERE id=? AND name!=?;",
params![name, chat_id, name],
)?;
}
Ok(())
}
pub fn update_special_chat_names(context: &Context) -> Result<(), Error> {
update_special_chat_name(context, DC_CONTACT_ID_DEVICE, StockMessage::DeviceMessages)?;
update_special_chat_name(context, DC_CONTACT_ID_SELF, StockMessage::SavedMessages)?;
Ok(())
}
pub fn create_or_lookup_by_contact_id(
context: &Context,
contact_id: u32,