mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 09:56:35 +03:00
feat: Chat::get_color(): Use grpid, if present, instead of name
While testing the previous commit i understood that it's better to try giving different colors to groups, particularly if their names are equal so that they visually differ, and at the same time preserve the color if the group is renamed. Using `grpid` solves this. So let groups change colors once and forever.
This commit is contained in:
@@ -1798,7 +1798,7 @@ impl Chat {
|
||||
/// Returns chat avatar color.
|
||||
///
|
||||
/// For 1:1 chats, the color is calculated from the contact's address.
|
||||
/// For group chats the color is calculated from the chat name.
|
||||
/// For group chats the color is calculated from the grpid, if present, or the chat name.
|
||||
pub async fn get_color(&self, context: &Context) -> Result<u32> {
|
||||
let mut color = 0;
|
||||
|
||||
@@ -1809,6 +1809,8 @@ impl Chat {
|
||||
color = contact.get_color();
|
||||
}
|
||||
}
|
||||
} else if !self.grpid.is_empty() {
|
||||
color = str_to_color(&self.grpid);
|
||||
} else {
|
||||
color = str_to_color(&self.name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user