Commit 44d5f71b2d
Unregistered key
Layout: unified · split
src/base.rs +3 −1
| @@ -869,6 +869,7 @@ impl EventLocation { | ||
| 869 | 869 | |
| 870 | 870 | #[derive(Clone, Debug, Default, Eq, PartialEq)] |
| 871 | 871 | pub struct UnreadInfo { |
| 872 | pub(crate) unread_mark: bool, | |
| 872 | 873 | pub(crate) unread_messages: u64, |
| 873 | 874 | pub(crate) unread_notifications: u64, |
| 874 | 875 | pub(crate) unread_mentions: u64, |
| @@ -877,7 +878,7 @@ pub struct UnreadInfo { | ||
| 877 | 878 | |
| 878 | 879 | impl UnreadInfo { |
| 879 | 880 | pub fn is_unread(&self) -> bool { |
| 880 | self.unread_notifications > 0 || self.unread_mentions > 0 | |
| 881 | self.unread_mark || self.unread_notifications > 0 || self.unread_mentions > 0 | |
| 881 | 882 | } |
| 882 | 883 | |
| 883 | 884 | pub fn has_mention(&self) -> bool { |
| @@ -1285,6 +1286,7 @@ impl RoomInfo { | ||
| 1285 | 1286 | .find(|(_, msg)| !matches!(&msg.event, MessageEvent::State(..))); |
| 1286 | 1287 | |
| 1287 | 1288 | UnreadInfo { |
| 1289 | unread_mark: room.is_marked_unread(), | |
| 1288 | 1290 | unread_messages: room.num_unread_messages(), |
| 1289 | 1291 | unread_notifications: room.num_unread_notifications(), |
| 1290 | 1292 | unread_mentions: room.num_unread_mentions(), |
src/windows/mod.rs +4 −1
| @@ -143,7 +143,7 @@ fn name_and_labels<'a>( | ||
| 143 | 143 | |
| 144 | 144 | if unread.unread_mentions > 0 { |
| 145 | 145 | labels.push(vec![Span::styled("Unread Mention", style)]); |
| 146 | } else if unread.unread_notifications > 0 || unread.unread_messages > 0 { | |
| 146 | } else if unread.is_unread() { | |
| 147 | 147 | labels.push(vec![Span::styled("Unread", style)]); |
| 148 | 148 | } |
| 149 | 149 | |
| @@ -1816,6 +1816,7 @@ mod tests { | ||
| 1816 | 1816 | name: "Room 1", |
| 1817 | 1817 | unread: UnreadInfo { |
| 1818 | 1818 | latest: None, |
| 1819 | unread_mark: false, | |
| 1819 | 1820 | unread_messages: 0, |
| 1820 | 1821 | unread_notifications: 0, |
| 1821 | 1822 | unread_mentions: 0, |
| @@ -1830,6 +1831,7 @@ mod tests { | ||
| 1830 | 1831 | name: "Room 2", |
| 1831 | 1832 | unread: UnreadInfo { |
| 1832 | 1833 | latest: Some(MessageTimeStamp::OriginServer(40u32.into())), |
| 1834 | unread_mark: false, | |
| 1833 | 1835 | unread_messages: 0, |
| 1834 | 1836 | unread_notifications: 0, |
| 1835 | 1837 | unread_mentions: 0, |
| @@ -1844,6 +1846,7 @@ mod tests { | ||
| 1844 | 1846 | name: "Room 3", |
| 1845 | 1847 | unread: UnreadInfo { |
| 1846 | 1848 | latest: Some(MessageTimeStamp::OriginServer(20u32.into())), |
| 1849 | unread_mark: false, | |
| 1847 | 1850 | unread_messages: 0, |
| 1848 | 1851 | unread_notifications: 0, |
| 1849 | 1852 | unread_mentions: 0, |