Commit 0dcf23d63f
Unregistered key
Layout: unified · split
src/config/mod.rs +12 −4
| @@ -1690,16 +1690,24 @@ impl ApplicationSettings { | |||
| 1690 | Ok(()) | 1690 | Ok(()) |
| 1691 | } | 1691 | } |
| 1692 | 1692 | ||
| 1693 | pub fn get_user_char_span(&self, user_id: &UserId) -> Span<'_> { | 1693 | pub fn get_user_char_span(&self, user_id: &UserId, info: &RoomInfo) -> Span<'_> { |
| 1694 | let (color, c) = self | 1694 | let (color, configured_name) = self |
| 1695 | .tunables | 1695 | .tunables |
| 1696 | .users | 1696 | .users |
| 1697 | .get(user_id) | 1697 | .get(user_id) |
| 1698 | .map(|user| (user.color, user.name.as_ref().and_then(|s| s.chars().next()))) | 1698 | .map(|user| (user.color, user.name.as_deref())) |
| 1699 | .unwrap_or_default(); | 1699 | .unwrap_or_default(); |
| 1700 | 1700 | ||
| 1701 | let style = self.theme.users.style(user_id.as_str(), color); | 1701 | let style = self.theme.users.style(user_id.as_str(), color); |
| 1702 | let c = c.unwrap_or_else(|| user_id.localpart().chars().next().unwrap_or(' ')); | 1702 | let c = configured_name |
| 1703 | .and_then(|name| name.chars().next()) | ||
| 1704 | .or_else(|| { | ||
| 1705 | info.display_names | ||
| 1706 | .get(user_id) | ||
| 1707 | .and_then(|name| name.chars().next()) | ||
| 1708 | .filter(char::is_ascii) | ||
| 1709 | }) | ||
| 1710 | .unwrap_or_else(|| user_id.localpart().chars().next().unwrap_or(' ')); | ||
| 1703 | 1711 | ||
| 1704 | Span::styled(String::from(c), style) | 1712 | Span::styled(String::from(c), style) |
| 1705 | } | 1713 | } |
src/message/mod.rs +2 −1
| @@ -807,7 +807,8 @@ impl<'a> MessageFormatter<'a> { | |||
| 807 | line.push(time); | 807 | line.push(time); |
| 808 | 808 | ||
| 809 | // Show read receipts. | 809 | // Show read receipts. |
| 810 | let user_char = |user: OwnedUserId| -> Span { settings.get_user_char_span(&user) }; | 810 | let user_char = |
| 811 | |user: OwnedUserId| -> Span { settings.get_user_char_span(&user, self.info) }; | ||
| 811 | 812 | ||
| 812 | let a = self.read.pop().map(user_char).unwrap_or_else(|| Span::raw(" ")); | 813 | let a = self.read.pop().map(user_char).unwrap_or_else(|| Span::raw(" ")); |
| 813 | let b = self.read.pop().map(user_char).unwrap_or_else(|| Span::raw(" ")); | 814 | let b = self.read.pop().map(user_char).unwrap_or_else(|| Span::raw(" ")); |