Commit e5b284ed19

e5b284ed19cb99f79a0cbaca9e2339b9171e6d6d

parent: 0f17bbfa17

Unregistered key

Ulyssa <git@ulyssa.dev> · 2024-04-02 15:42 UTC
committer: <noreply@github.com>

Use color overrides for users when `message_user_color` is enabled (#245)

Layout: unified · split

src/config.rs +6 −5
@@ -912,15 +912,16 @@ impl ApplicationSettings {
912 .unwrap_or_default() 912 .unwrap_or_default()
913 } 913 }
914 914
915 pub fn get_user_style(&self, user_id: &UserId) -> Style { 915 pub fn get_user_color(&self, user_id: &UserId) -> Color {
916 let color = self 916 self.tunables
917 .tunables
918 .users 917 .users
919 .get(user_id) 918 .get(user_id)
920 .and_then(|user| user.color.as_ref().map(|c| c.0)) 919 .and_then(|user| user.color.as_ref().map(|c| c.0))
921 .unwrap_or_else(|| user_color(user_id.as_str())); 920 .unwrap_or_else(|| user_color(user_id.as_str()))
921 }
922 922
923 user_style_from_color(color) 923 pub fn get_user_style(&self, user_id: &UserId) -> Style {
924 user_style_from_color(self.get_user_color(user_id))
924 } 925 }
925 926
926 pub fn get_user_span<'a>(&self, user_id: &'a UserId, info: &'a RoomInfo) -> Span<'a> { 927 pub fn get_user_span<'a>(&self, user_id: &'a UserId, info: &'a RoomInfo) -> Span<'a> {
src/message/mod.rs +1 −1
@@ -863,7 +863,7 @@ impl Message {
863 } 863 }
864 864
865 if settings.tunables.message_user_color { 865 if settings.tunables.message_user_color {
866 let color = crate::config::user_color(self.sender.as_str()); 866 let color = settings.get_user_color(&self.sender);
867 style = style.fg(color); 867 style = style.fg(color);
868 } 868 }
869 869