mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 01:46:34 +03:00
fix searching for localized device chats
This commit is contained in:
committed by
Alexander Krotov
parent
6702ef4a71
commit
cb2a1147f0
22
src/chat.rs
22
src/chat.rs
@@ -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,
|
||||
|
||||
@@ -162,6 +162,10 @@ impl Chatlist {
|
||||
let query = query.trim().to_string();
|
||||
ensure!(!query.is_empty(), "missing query");
|
||||
|
||||
// allow searching over special names that may change at any time
|
||||
// when the ui calls set_stock_translation()
|
||||
update_special_chat_names(context)?;
|
||||
|
||||
let str_like_cmd = format!("%{}%", query);
|
||||
context.sql.query_map(
|
||||
"SELECT c.id, m.id
|
||||
|
||||
Reference in New Issue
Block a user