diff --git a/assets/icon-saved-messages.png b/assets/icon-saved-messages.png new file mode 100644 index 000000000..e189cb863 Binary files /dev/null and b/assets/icon-saved-messages.png differ diff --git a/src/chat.rs b/src/chat.rs index cc0f9a044..b52601403 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -100,7 +100,7 @@ impl Chat { } if chat.param.exists(Param::Selftalk) { - chat.name = context.stock_str(StockMessage::SelfMsg).into(); + chat.name = context.stock_str(StockMessage::SavedMessages).into(); } else if chat.param.exists(Param::Devicetalk) { chat.name = context.stock_str(StockMessage::DeviceMessages).into(); } @@ -603,6 +603,20 @@ fn copy_device_icon_to_blobs(context: &Context) -> Result { Ok(blob.as_name().to_string()) } +pub fn update_saved_messages_icon(context: &Context) -> Result<(), Error> { + // if there is no saved-messages chat, there is nothing to update. this is no error. + if let Ok((chat_id, _)) = lookup_by_contact_id(context, DC_CONTACT_ID_SELF) { + let icon = include_bytes!("../assets/icon-saved-messages.png"); + let blob = BlobObject::create(context, "icon-saved-messages.png".to_string(), icon)?; + let icon = blob.as_name().to_string(); + + let mut chat = Chat::load_from_db(context, chat_id)?; + chat.param.set(Param::ProfileImage, icon); + chat.update_param(context)?; + } + Ok(()) +} + pub fn create_or_lookup_by_contact_id( context: &Context, contact_id: u32, @@ -652,6 +666,10 @@ pub fn create_or_lookup_by_contact_id( params![], )?; + if contact_id == DC_CONTACT_ID_SELF { + update_saved_messages_icon(context)?; + } + Ok((chat_id, create_blocked)) } diff --git a/src/sql.rs b/src/sql.rs index 2923083b4..396b939d3 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -7,6 +7,7 @@ use std::time::Duration; use rusqlite::{Connection, OpenFlags, Statement, NO_PARAMS}; use thread_local_object::ThreadLocal; +use crate::chat::update_saved_messages_icon; use crate::constants::ShowEmails; use crate::context::Context; use crate::dc_tools::*; @@ -495,6 +496,7 @@ fn open( let mut dbversion = dbversion_before_update; let mut recalc_fingerprints = 0; let mut update_file_paths = 0; + let mut update_icons = false; if dbversion < 1 { info!(context, "[migration] v1"); @@ -822,6 +824,11 @@ fn open( } sql.set_raw_config_int(context, "dbversion", 57)?; } + if dbversion < 58 { + info!(context, "[migration] v58"); + update_icons = true; + sql.set_raw_config_int(context, "dbversion", 58)?; + } // (2) updates that require high-level objects // (the structure is complete now and all objects are usable) @@ -873,6 +880,9 @@ fn open( sql.set_raw_config(context, "backup_for", None)?; } + if update_icons { + update_saved_messages_icon(context)?; + } } info!(context, "Opened {:?}.", dbfile.as_ref(),); diff --git a/src/stock.rs b/src/stock.rs index 7bafccb58..54ae4a23b 100644 --- a/src/stock.rs +++ b/src/stock.rs @@ -112,8 +112,10 @@ pub enum StockMessage { Location = 66, #[strum(props(fallback = "Sticker"))] Sticker = 67, - #[strum(props(fallback = "Device Messages"))] + #[strum(props(fallback = "Device messages"))] DeviceMessages = 68, + #[strum(props(fallback = "Saved messages"))] + SavedMessages = 69, } impl StockMessage {