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:
iequidoo
2025-08-21 17:55:48 -03:00
committed by iequidoo
parent 11e3480fe8
commit d0cb2110e6
2 changed files with 17 additions and 3 deletions

View File

@@ -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);
}