From c16b29b1265cdb0b5d577451749b83f99bc28060 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 8 Aug 2025 01:15:27 +0000 Subject: [PATCH] feat: do not replace avatar for address-contact profiles Key-contacts and address-contacts do not appear in the same lists in the UI, so there is no need to distinguish between the two. Letter icon is renamed from "address contact icon" to "unencrypted chat icon" to make it clear that the icon distinguishes unencrypted chats from encrypted chats as it is also used for unencrypted group chats and is most helpful in the chatlists where a mix of encrypted and unencrypted chats is displayed. --- ...ss-contact.png => icon-unencrypted-chat.png} | Bin ...ss-contact.svg => icon-unencrypted-chat.svg} | 0 src/chat.rs | 16 ++++++++-------- src/contact.rs | 16 +--------------- 4 files changed, 9 insertions(+), 23 deletions(-) rename assets/{icon-address-contact.png => icon-unencrypted-chat.png} (100%) rename assets/{icon-address-contact.svg => icon-unencrypted-chat.svg} (100%) diff --git a/assets/icon-address-contact.png b/assets/icon-unencrypted-chat.png similarity index 100% rename from assets/icon-address-contact.png rename to assets/icon-unencrypted-chat.png diff --git a/assets/icon-address-contact.svg b/assets/icon-unencrypted-chat.svg similarity index 100% rename from assets/icon-address-contact.svg rename to assets/icon-unencrypted-chat.svg diff --git a/src/chat.rs b/src/chat.rs index d3c5ee7fb..df23fa2ac 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1771,6 +1771,12 @@ impl Chat { return Ok(Some(get_device_icon(context).await?)); } else if self.is_self_talk() { return Ok(Some(get_saved_messages_icon(context).await?)); + } else if !self.is_encrypted(context).await? { + // This is an unencrypted chat, show a special avatar that marks it as such. + return Ok(Some(get_abs_path( + context, + Path::new(&get_unencrypted_chat_icon(context).await?), + ))); } else if self.typ == Chattype::Single { // For 1:1 chats, we always use the same avatar as for the contact // This is before the `self.is_encrypted()` check, because that function @@ -1780,12 +1786,6 @@ impl Chat { let contact = Contact::get_by_id(context, *contact_id).await?; return contact.get_profile_image(context).await; } - } else if !self.is_encrypted(context).await? { - // This is an address-contact chat, show a special avatar that marks it as such - return Ok(Some(get_abs_path( - context, - Path::new(&get_address_contact_icon(context).await?), - ))); } else if let Some(image_rel) = self.param.get(Param::ProfileImage) { // Load the group avatar, or the device-chat / saved-messages icon if !image_rel.is_empty() { @@ -2490,11 +2490,11 @@ pub(crate) async fn get_archive_icon(context: &Context) -> Result { .await } -pub(crate) async fn get_address_contact_icon(context: &Context) -> Result { +pub(crate) async fn get_unencrypted_chat_icon(context: &Context) -> Result { get_asset_icon( context, "icon-address-contact", - include_bytes!("../assets/icon-address-contact.png"), + include_bytes!("../assets/icon-unencrypted-chat.png"), ) .await } diff --git a/src/contact.rs b/src/contact.rs index 7c902555e..f04334f39 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -268,7 +268,7 @@ pub async fn make_vcard(context: &Context, contacts: &[ContactId]) -> Result None, Some(path) => tokio::fs::read(path) .await @@ -1545,17 +1545,6 @@ impl Contact { /// This is the image set by each remote user on their own /// using set_config(context, "selfavatar", image). pub async fn get_profile_image(&self, context: &Context) -> Result> { - self.get_profile_image_ex(context, true).await - } - - /// Get the contact's profile image. - /// This is the image set by each remote user on their own - /// using set_config(context, "selfavatar", image). - async fn get_profile_image_ex( - &self, - context: &Context, - show_fallback_icon: bool, - ) -> Result> { if self.id == ContactId::SELF { if let Some(p) = context.get_config(Config::Selfavatar).await? { return Ok(Some(PathBuf::from(p))); // get_config() calls get_abs_path() internally already @@ -1563,9 +1552,6 @@ impl Contact { } else if self.id == ContactId::DEVICE { return Ok(Some(chat::get_device_icon(context).await?)); } - if show_fallback_icon && !self.id.is_special() && !self.is_key_contact() { - return Ok(Some(chat::get_address_contact_icon(context).await?)); - } if let Some(image_rel) = self.param.get(Param::ProfileImage) { if !image_rel.is_empty() { return Ok(Some(get_abs_path(context, Path::new(image_rel))));