Skip to content

Commit

Permalink
Use color overrides for users when message_user_color is enabled (#245
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ulyssa authored Apr 2, 2024
1 parent 0f17bbf commit e5b284e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,15 +912,16 @@ impl ApplicationSettings {
.unwrap_or_default()
}

pub fn get_user_style(&self, user_id: &UserId) -> Style {
let color = self
.tunables
pub fn get_user_color(&self, user_id: &UserId) -> Color {
self.tunables
.users
.get(user_id)
.and_then(|user| user.color.as_ref().map(|c| c.0))
.unwrap_or_else(|| user_color(user_id.as_str()));
.unwrap_or_else(|| user_color(user_id.as_str()))
}

user_style_from_color(color)
pub fn get_user_style(&self, user_id: &UserId) -> Style {
user_style_from_color(self.get_user_color(user_id))
}

pub fn get_user_span<'a>(&self, user_id: &'a UserId, info: &'a RoomInfo) -> Span<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ impl Message {
}

if settings.tunables.message_user_color {
let color = crate::config::user_color(self.sender.as_str());
let color = settings.get_user_color(&self.sender);
style = style.fg(color);
}

Expand Down

0 comments on commit e5b284e

Please sign in to comment.