diff --git a/assets/icon-group.png b/assets/icon-group.png new file mode 100644 index 000000000..aebd7430c Binary files /dev/null and b/assets/icon-group.png differ diff --git a/assets/icon-group.svg b/assets/icon-group.svg new file mode 100644 index 000000000..d6fef9598 --- /dev/null +++ b/assets/icon-group.svg @@ -0,0 +1,68 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/chat.rs b/src/chat.rs index b6d593822..6633e7fbe 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1451,6 +1451,12 @@ impl Chat { if let Ok(image_rel) = get_archive_icon(context).await { return Ok(Some(get_abs_path(context, Path::new(&image_rel)))); } + } + + if self.typ == Chattype::Group { + if let Ok(image_rel) = get_group_icon(context).await { + return Ok(Some(get_abs_path(context, Path::new(&image_rel)))); + } } else if self.typ == Chattype::Single { let contacts = get_chat_contacts(context, self.id).await?; if let Some(contact_id) = contacts.first() { @@ -1983,6 +1989,21 @@ pub(crate) async fn get_broadcast_icon(context: &Context) -> Result { Ok(icon) } +pub(crate) async fn get_group_icon(context: &Context) -> Result { + if let Some(icon) = context.sql.get_raw_config("icon-group").await? { + return Ok(icon); + } + + let icon = include_bytes!("../assets/icon-group.png"); + let blob = BlobObject::create(context, "icon-group.png", icon).await?; + let icon = blob.as_name().to_string(); + context + .sql + .set_raw_config("icon-group", Some(&icon)) + .await?; + Ok(icon) +} + pub(crate) async fn get_archive_icon(context: &Context) -> Result { if let Some(icon) = context.sql.get_raw_config("icon-archive").await? { return Ok(icon);