Commit c885a7cc7c
Unregistered key
Layout: unified · split
config.full.toml +1
| @@ -36,6 +36,7 @@ reaction_display = true | |||
| 36 | reaction_shortcode_display = false | 36 | reaction_shortcode_display = false |
| 37 | read_receipt_display = true | 37 | read_receipt_display = true |
| 38 | read_receipt_send = true | 38 | read_receipt_send = true |
| 39 | room_labels = ["membership", "muted", "tags"] | ||
| 39 | request_timeout = 10000 | 40 | request_timeout = 10000 |
| 40 | sync_delay_ms = 1000 | 41 | sync_delay_ms = 1000 |
| 41 | typing_notice_display = true | 42 | typing_notice_display = true |
docs/iamb.1 +3 −1
| @@ -242,7 +242,9 @@ Note that | |||
| 242 | .Dq mentions | 242 | .Dq mentions |
| 243 | and | 243 | and |
| 244 | .Dq keywords | 244 | .Dq keywords |
| 245 | are aliases for the same behaviour. | 245 | are aliases for the same behaviour, and the room will be labeled |
| 246 | .Dq Calmed | ||
| 247 | in room lists. | ||
| 246 | .It Sy ":room notify unset" | 248 | .It Sy ":room notify unset" |
| 247 | Unset any room-level notification configuration. | 249 | Unset any room-level notification configuration. |
| 248 | .It Sy ":room notify show" | 250 | .It Sy ":room notify show" |
docs/iamb.5 +21
| @@ -284,6 +284,27 @@ A message must be sent to the room before marking it read. | |||
| 284 | Defines whether or not read confirmations are displayed. | 284 | Defines whether or not read confirmations are displayed. |
| 285 | .It Sy request_timeout | 285 | .It Sy request_timeout |
| 286 | Defines the maximum time per request in seconds. | 286 | Defines the maximum time per request in seconds. |
| 287 | .It Sy room_labels | ||
| 288 | Defines which kinds of labels to put next to room names and what order to show the information in. | ||
| 289 | This defaults to | ||
| 290 | .Sy ["unread",\ "membership",\ "tags",\ "muted",\ "type"] . | ||
| 291 | The possible values and the information shown are: | ||
| 292 | .Bl -tag -width Ds | ||
| 293 | .It Sy membership | ||
| 294 | Show whether you're not currently a room member, such as when you're invited to a room. | ||
| 295 | .It Sy muted | ||
| 296 | Show | ||
| 297 | .Dq Muted | ||
| 298 | and | ||
| 299 | .Dq Calmed | ||
| 300 | if the room doesn't notify for all new messages. | ||
| 301 | .It Sy tags | ||
| 302 | Show if the room has been tagged, such as a Favorite or Low Priority room. | ||
| 303 | .It Sy type | ||
| 304 | Show if this is a regular room, a DM or a space when the current window shows multiple kinds. | ||
| 305 | .It Sy unread | ||
| 306 | Show if a non-muted, non-calmed room has unread messages or mentions. | ||
| 307 | .El | ||
| 287 | .It Sy send_on_enter | 308 | .It Sy send_on_enter |
| 288 | If | 309 | If |
| 289 | .Sy true | 310 | .Sy true |
src/base.rs +20
| @@ -1290,6 +1290,21 @@ impl DisplayNameStore { | |||
| 1290 | } | 1290 | } |
| 1291 | } | 1291 | } |
| 1292 | 1292 | ||
| 1293 | bitflags::bitflags! { | ||
| 1294 | /// Additional information about a room. | ||
| 1295 | #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] | ||
| 1296 | pub struct RoomInfoFlags: u32 { | ||
| 1297 | /// No flags specified. | ||
| 1298 | const NONE = 0b00000000; | ||
| 1299 | |||
| 1300 | /// All notifications for this room have been muted. | ||
| 1301 | const MUTED = 0b00000001; | ||
| 1302 | |||
| 1303 | /// Non-mention/keyword notifications for this room have been muted. | ||
| 1304 | const CALMED = 0b00000010; | ||
| 1305 | } | ||
| 1306 | } | ||
| 1307 | |||
| 1293 | /// Information about room's the user's joined. | 1308 | /// Information about room's the user's joined. |
| 1294 | pub struct RoomInfo { | 1309 | pub struct RoomInfo { |
| 1295 | /// The display name for this room. | 1310 | /// The display name for this room. |
| @@ -1298,6 +1313,8 @@ pub struct RoomInfo { | |||
| 1298 | /// The tags placed on this room. | 1313 | /// The tags placed on this room. |
| 1299 | pub tags: Option<Tags>, | 1314 | pub tags: Option<Tags>, |
| 1300 | 1315 | ||
| 1316 | pub flags: RoomInfoFlags, | ||
| 1317 | |||
| 1301 | /// A map of event IDs to where they are stored in this struct. | 1318 | /// A map of event IDs to where they are stored in this struct. |
| 1302 | pub keys: HashMap<OwnedEventId, EventLocation>, | 1319 | pub keys: HashMap<OwnedEventId, EventLocation>, |
| 1303 | pub echo_keys: HashMap<OwnedTransactionId, EchoLocation>, | 1320 | pub echo_keys: HashMap<OwnedTransactionId, EchoLocation>, |
| @@ -1360,6 +1377,7 @@ impl Default for RoomInfo { | |||
| 1360 | name: Default::default(), | 1377 | name: Default::default(), |
| 1361 | tags: Default::default(), | 1378 | tags: Default::default(), |
| 1362 | keys: Default::default(), | 1379 | keys: Default::default(), |
| 1380 | flags: Default::default(), | ||
| 1363 | echo_keys: Default::default(), | 1381 | echo_keys: Default::default(), |
| 1364 | event_receipts: Default::default(), | 1382 | event_receipts: Default::default(), |
| 1365 | user_receipts: Default::default(), | 1383 | user_receipts: Default::default(), |
| @@ -2560,6 +2578,7 @@ impl ChatStore { | |||
| 2560 | name: String, | 2578 | name: String, |
| 2561 | tags: Option<Tags>, | 2579 | tags: Option<Tags>, |
| 2562 | aliases: Vec<OwnedRoomAliasId>, | 2580 | aliases: Vec<OwnedRoomAliasId>, |
| 2581 | flags: RoomInfoFlags, | ||
| 2563 | ) { | 2582 | ) { |
| 2564 | for alias in aliases { | 2583 | for alias in aliases { |
| 2565 | self.aliases.insert(alias, room_id.clone()); | 2584 | self.aliases.insert(alias, room_id.clone()); |
| @@ -2567,6 +2586,7 @@ impl ChatStore { | |||
| 2567 | 2586 | ||
| 2568 | let info = self.rooms.get_or_default(room_id); | 2587 | let info = self.rooms.get_or_default(room_id); |
| 2569 | info.name = name.into(); | 2588 | info.name = name.into(); |
| 2589 | info.flags = flags; | ||
| 2570 | info.tags = tags; | 2590 | info.tags = tags; |
| 2571 | } | 2591 | } |
| 2572 | } | 2592 | } |
src/config/mod.rs +31
| @@ -69,6 +69,14 @@ const DEFAULT_SPACE_SORT: [SortColumn<SortFieldSpace>; 3] = [ | |||
| 69 | SortColumn(SortFieldSpace::SpaceOrder, SortOrder::Ascending), | 69 | SortColumn(SortFieldSpace::SpaceOrder, SortOrder::Ascending), |
| 70 | ]; | 70 | ]; |
| 71 | 71 | ||
| 72 | const DEFAULT_ROOM_LABELS: [RoomLabel; 5] = [ | ||
| 73 | RoomLabel::Unread, | ||
| 74 | RoomLabel::Membership, | ||
| 75 | RoomLabel::Tags, | ||
| 76 | RoomLabel::Muted, | ||
| 77 | RoomLabel::Type, | ||
| 78 | ]; | ||
| 79 | |||
| 72 | const DEFAULT_ENABLE_TITLE: bool = true; | 80 | const DEFAULT_ENABLE_TITLE: bool = true; |
| 73 | const DEFAULT_REQ_TIMEOUT: u64 = 120; | 81 | const DEFAULT_REQ_TIMEOUT: u64 = 120; |
| 74 | const DEFAULT_SYNC_FREQUENCY: u64 = 250; | 82 | const DEFAULT_SYNC_FREQUENCY: u64 = 250; |
| @@ -462,6 +470,18 @@ impl Visitor<'_> for EncryptionIndicatorLocationVisitor { | |||
| 462 | } | 470 | } |
| 463 | } | 471 | } |
| 464 | 472 | ||
| 473 | /// Types of room labels to display in room lists. | ||
| 474 | #[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq)] | ||
| 475 | #[serde(rename_all = "kebab-case")] | ||
| 476 | #[repr(u8)] | ||
| 477 | pub enum RoomLabel { | ||
| 478 | Membership, | ||
| 479 | Muted, | ||
| 480 | Tags, | ||
| 481 | Type, | ||
| 482 | Unread, | ||
| 483 | } | ||
| 484 | |||
| 465 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)] | 485 | #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)] |
| 466 | #[serde(rename_all = "lowercase")] | 486 | #[serde(rename_all = "lowercase")] |
| 467 | pub enum UserDisplayStyle { | 487 | pub enum UserDisplayStyle { |
| @@ -844,6 +864,7 @@ pub struct TunableValues { | |||
| 844 | pub read_receipt_send: bool, | 864 | pub read_receipt_send: bool, |
| 845 | pub read_receipt_trigger: ReadReceiptTrigger, | 865 | pub read_receipt_trigger: ReadReceiptTrigger, |
| 846 | pub read_receipt_display: bool, | 866 | pub read_receipt_display: bool, |
| 867 | pub room_labels: Vec<RoomLabel>, | ||
| 847 | pub request_timeout: u64, | 868 | pub request_timeout: u64, |
| 848 | pub sort: SortValues, | 869 | pub sort: SortValues, |
| 849 | pub state_event_display: bool, | 870 | pub state_event_display: bool, |
| @@ -904,6 +925,7 @@ pub struct Tunables { | |||
| 904 | pub read_receipt_send: Option<bool>, | 925 | pub read_receipt_send: Option<bool>, |
| 905 | pub read_receipt_trigger: Option<ReadReceiptTrigger>, | 926 | pub read_receipt_trigger: Option<ReadReceiptTrigger>, |
| 906 | pub read_receipt_display: Option<bool>, | 927 | pub read_receipt_display: Option<bool>, |
| 928 | pub room_labels: Option<Vec<RoomLabel>>, | ||
| 907 | pub request_timeout: Option<u64>, | 929 | pub request_timeout: Option<u64>, |
| 908 | pub state_event_display: Option<bool>, | 930 | pub state_event_display: Option<bool>, |
| 909 | pub sync_delay_ms: Option<u64>, | 931 | pub sync_delay_ms: Option<u64>, |
| @@ -961,6 +983,7 @@ impl Tunables { | |||
| 961 | read_receipt_send: self.read_receipt_send.or(other.read_receipt_send), | 983 | read_receipt_send: self.read_receipt_send.or(other.read_receipt_send), |
| 962 | read_receipt_trigger: self.read_receipt_trigger.or(other.read_receipt_trigger), | 984 | read_receipt_trigger: self.read_receipt_trigger.or(other.read_receipt_trigger), |
| 963 | read_receipt_display: self.read_receipt_display.or(other.read_receipt_display), | 985 | read_receipt_display: self.read_receipt_display.or(other.read_receipt_display), |
| 986 | room_labels: self.room_labels.or(other.room_labels), | ||
| 964 | request_timeout: self.request_timeout.or(other.request_timeout), | 987 | request_timeout: self.request_timeout.or(other.request_timeout), |
| 965 | state_event_display: self.state_event_display.or(other.state_event_display), | 988 | state_event_display: self.state_event_display.or(other.state_event_display), |
| 966 | sync_delay_ms: self.sync_delay_ms.or(other.sync_delay_ms), | 989 | sync_delay_ms: self.sync_delay_ms.or(other.sync_delay_ms), |
| @@ -1009,6 +1032,7 @@ impl Tunables { | |||
| 1009 | read_receipt_send: self.read_receipt_send.unwrap_or(true), | 1032 | read_receipt_send: self.read_receipt_send.unwrap_or(true), |
| 1010 | read_receipt_trigger: self.read_receipt_trigger.unwrap_or_default(), | 1033 | read_receipt_trigger: self.read_receipt_trigger.unwrap_or_default(), |
| 1011 | read_receipt_display: self.read_receipt_display.unwrap_or(true), | 1034 | read_receipt_display: self.read_receipt_display.unwrap_or(true), |
| 1035 | room_labels: self.room_labels.unwrap_or_else(|| DEFAULT_ROOM_LABELS.to_vec()), | ||
| 1012 | request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT), | 1036 | request_timeout: self.request_timeout.unwrap_or(DEFAULT_REQ_TIMEOUT), |
| 1013 | state_event_display: self.state_event_display.unwrap_or(true), | 1037 | state_event_display: self.state_event_display.unwrap_or(true), |
| 1014 | sync_delay_ms: self.sync_delay_ms.unwrap_or(DEFAULT_SYNC_FREQUENCY), | 1038 | sync_delay_ms: self.sync_delay_ms.unwrap_or(DEFAULT_SYNC_FREQUENCY), |
| @@ -1996,6 +2020,13 @@ mod tests { | |||
| 1996 | assert!(serde_json::from_str::<NotifyVia>(r#""""#).is_err()); | 2020 | assert!(serde_json::from_str::<NotifyVia>(r#""""#).is_err()); |
| 1997 | } | 2021 | } |
| 1998 | 2022 | ||
| 2023 | #[test] | ||
| 2024 | fn test_parse_room_labels() { | ||
| 2025 | assert_eq!(RoomLabel::Membership, serde_json::from_str(r#""membership""#).unwrap()); | ||
| 2026 | assert_eq!(RoomLabel::Tags, serde_json::from_str(r#""tags""#).unwrap()); | ||
| 2027 | assert_eq!(RoomLabel::Type, serde_json::from_str(r#""type""#).unwrap()); | ||
| 2028 | } | ||
| 2029 | |||
| 1999 | #[test] | 2030 | #[test] |
| 2000 | fn test_parse_cursor_shape() { | 2031 | fn test_parse_cursor_shape() { |
| 2001 | assert_eq!(CursorShape::Auto, CursorShape::default()); | 2032 | assert_eq!(CursorShape::Auto, CursorShape::default()); |
src/prelude.rs +1
| @@ -89,6 +89,7 @@ pub use crate::base::{ | |||
| 89 | RoomAction, | 89 | RoomAction, |
| 90 | RoomFocus, | 90 | RoomFocus, |
| 91 | RoomInfo, | 91 | RoomInfo, |
| 92 | RoomInfoFlags, | ||
| 92 | SendAction, | 93 | SendAction, |
| 93 | SpaceAction, | 94 | SpaceAction, |
| 94 | TimelineAction, | 95 | TimelineAction, |
src/tests.rs +1
| @@ -167,6 +167,7 @@ pub fn mock_tunables() -> TunableValues { | |||
| 167 | read_receipt_send: true, | 167 | read_receipt_send: true, |
| 168 | read_receipt_trigger: Default::default(), | 168 | read_receipt_trigger: Default::default(), |
| 169 | read_receipt_display: true, | 169 | read_receipt_display: true, |
| 170 | room_labels: Default::default(), | ||
| 170 | request_timeout: 120, | 171 | request_timeout: 120, |
| 171 | sort: SortOverrides::default().values(), | 172 | sort: SortOverrides::default().values(), |
| 172 | state_event_display: true, | 173 | state_event_display: true, |
src/windows/mod.rs +67 −41
| @@ -31,6 +31,7 @@ use crate::base::{ | |||
| 31 | SpaceInfo, | 31 | SpaceInfo, |
| 32 | UnreadInfo, | 32 | UnreadInfo, |
| 33 | }; | 33 | }; |
| 34 | use crate::config::RoomLabel; | ||
| 34 | use crate::config::theme::ThemeRoomsValues; | 35 | use crate::config::theme::ThemeRoomsValues; |
| 35 | use crate::prelude::*; | 36 | use crate::prelude::*; |
| 36 | use crate::resolve_mxid; | 37 | use crate::resolve_mxid; |
| @@ -129,34 +130,6 @@ fn room_name_from_preview(preview: &RoomPreview) -> Cow<'_, str> { | |||
| 129 | format!("Empty Room (was {name})").into() | 130 | format!("Empty Room (was {name})").into() |
| 130 | } | 131 | } |
| 131 | 132 | ||
| 132 | fn name_and_labels<'a>( | ||
| 133 | name: &'a str, | ||
| 134 | unread: &UnreadInfo, | ||
| 135 | room_membership: MatrixRoomState, | ||
| 136 | name_style: Style, | ||
| 137 | tags_style: Style, | ||
| 138 | ) -> (Span<'a>, Vec<Vec<Span<'static>>>) { | ||
| 139 | let name = Span::styled(name, name_style); | ||
| 140 | |||
| 141 | let mut labels = vec![]; | ||
| 142 | |||
| 143 | match room_membership { | ||
| 144 | MatrixRoomState::Joined => {}, | ||
| 145 | MatrixRoomState::Left => labels.push(vec![Span::styled("Unjoined", tags_style)]), | ||
| 146 | MatrixRoomState::Banned => labels.push(vec![Span::styled("Banned", tags_style)]), | ||
| 147 | MatrixRoomState::Knocked => labels.push(vec![Span::styled("Knocked", tags_style)]), | ||
| 148 | MatrixRoomState::Invited => labels.push(vec![Span::styled("Invited", tags_style)]), | ||
| 149 | } | ||
| 150 | |||
| 151 | if unread.unread_mentions > 0 { | ||
| 152 | labels.push(vec![Span::styled("Unread Mention", tags_style)]); | ||
| 153 | } else if unread.is_unread() { | ||
| 154 | labels.push(vec![Span::styled("Unread", tags_style)]); | ||
| 155 | } | ||
| 156 | |||
| 157 | (name, labels) | ||
| 158 | } | ||
| 159 | |||
| 160 | /// Sort `Some` to be less than `None` so that list items with values come before those without. | 133 | /// Sort `Some` to be less than `None` so that list items with values come before those without. |
| 161 | #[inline] | 134 | #[inline] |
| 162 | fn some_cmp<T, F>(a: Option<T>, b: Option<T>, f: F) -> Ordering | 135 | fn some_cmp<T, F>(a: Option<T>, b: Option<T>, f: F) -> Ordering |
| @@ -1390,6 +1363,7 @@ pub struct GenericRoomItem { | |||
| 1390 | tags: Option<Tags>, | 1363 | tags: Option<Tags>, |
| 1391 | section: Option<ListSectionHeader>, | 1364 | section: Option<ListSectionHeader>, |
| 1392 | membership: MatrixRoomState, | 1365 | membership: MatrixRoomState, |
| 1366 | room_flags: RoomInfoFlags, | ||
| 1393 | unread: UnreadInfo, | 1367 | unread: UnreadInfo, |
| 1394 | room_type_show: bool, | 1368 | room_type_show: bool, |
| 1395 | room_type: RoomType, | 1369 | room_type: RoomType, |
| @@ -1407,6 +1381,7 @@ impl GenericRoomItem { | |||
| 1407 | let name = info.name.clone().unwrap_or_default(); | 1381 | let name = info.name.clone().unwrap_or_default(); |
| 1408 | let alias = room.canonical_alias(); | 1382 | let alias = room.canonical_alias(); |
| 1409 | let mut unread = info.unreads(room); | 1383 | let mut unread = info.unreads(room); |
| 1384 | let room_flags = info.flags; | ||
| 1410 | let tags = info.tags.clone(); | 1385 | let tags = info.tags.clone(); |
| 1411 | 1386 | ||
| 1412 | if room.is_space() && | 1387 | if room.is_space() && |
| @@ -1434,6 +1409,7 @@ impl GenericRoomItem { | |||
| 1434 | tags, | 1409 | tags, |
| 1435 | unread, | 1410 | unread, |
| 1436 | membership: room.state(), | 1411 | membership: room.state(), |
| 1412 | room_flags, | ||
| 1437 | room_type, | 1413 | room_type, |
| 1438 | room_type_show: true, | 1414 | room_type_show: true, |
| 1439 | section: None, | 1415 | section: None, |
| @@ -1459,6 +1435,7 @@ impl GenericRoomItem { | |||
| 1459 | alias: preview.canonical_alias.clone(), | 1435 | alias: preview.canonical_alias.clone(), |
| 1460 | tags: None, | 1436 | tags: None, |
| 1461 | membership, | 1437 | membership, |
| 1438 | room_flags: RoomInfoFlags::NONE, | ||
| 1462 | unread: Default::default(), | 1439 | unread: Default::default(), |
| 1463 | room_type, | 1440 | room_type, |
| 1464 | room_type_show: true, | 1441 | room_type_show: true, |
| @@ -1474,6 +1451,64 @@ impl GenericRoomItem { | |||
| 1474 | fn set_section<T: SortedSection>(&mut self, fields: &[SortColumn<T>]) { | 1451 | fn set_section<T: SortedSection>(&mut self, fields: &[SortColumn<T>]) { |
| 1475 | self.section = ListSectionHeader::for_room(self, fields); | 1452 | self.section = ListSectionHeader::for_room(self, fields); |
| 1476 | } | 1453 | } |
| 1454 | |||
| 1455 | /// Generate the list of labels to show for this room. | ||
| 1456 | fn name_and_labels<'a>( | ||
| 1457 | &'a self, | ||
| 1458 | name_style: Style, | ||
| 1459 | tags_style: Style, | ||
| 1460 | order: &[RoomLabel], | ||
| 1461 | ) -> (Span<'a>, Vec<Vec<Span<'a>>>) { | ||
| 1462 | let name = Span::styled(&self.name, name_style); | ||
| 1463 | |||
| 1464 | let mut labels = vec![]; | ||
| 1465 | |||
| 1466 | for label in order { | ||
| 1467 | match label { | ||
| 1468 | RoomLabel::Membership => { | ||
| 1469 | let label = match self.membership { | ||
| 1470 | MatrixRoomState::Joined => None, | ||
| 1471 | MatrixRoomState::Left => Some("Unjoined"), | ||
| 1472 | MatrixRoomState::Banned => Some("Banned"), | ||
| 1473 | MatrixRoomState::Knocked => Some("Knocked"), | ||
| 1474 | MatrixRoomState::Invited => Some("Invited"), | ||
| 1475 | }; | ||
| 1476 | |||
| 1477 | if let Some(label) = label { | ||
| 1478 | labels.push(vec![Span::styled(label, tags_style)]); | ||
| 1479 | } | ||
| 1480 | }, | ||
| 1481 | RoomLabel::Unread => { | ||
| 1482 | if self.unread.unread_mentions > 0 { | ||
| 1483 | labels.push(vec![Span::styled("Unread Mention", tags_style)]); | ||
| 1484 | } else if self.unread.is_unread() { | ||
| 1485 | labels.push(vec![Span::styled("Unread", tags_style)]); | ||
| 1486 | } | ||
| 1487 | }, | ||
| 1488 | RoomLabel::Muted => { | ||
| 1489 | if self.room_flags.contains(RoomInfoFlags::MUTED) { | ||
| 1490 | labels.push(vec![Span::styled("Muted", tags_style)]); | ||
| 1491 | } else if self.room_flags.contains(RoomInfoFlags::CALMED) { | ||
| 1492 | labels.push(vec![Span::styled("Calmed", tags_style)]); | ||
| 1493 | } | ||
| 1494 | }, | ||
| 1495 | RoomLabel::Type => { | ||
| 1496 | if self.room_type_show && | ||
| 1497 | let Some(label) = self.room_type.text() | ||
| 1498 | { | ||
| 1499 | labels.push(vec![Span::styled(label, tags_style)]); | ||
| 1500 | } | ||
| 1501 | }, | ||
| 1502 | RoomLabel::Tags => { | ||
| 1503 | if let Some(tags) = &self.tags { | ||
| 1504 | labels.extend(tags.keys().map(|t| tag_to_span(t, tags_style))); | ||
| 1505 | } | ||
| 1506 | }, | ||
| 1507 | } | ||
| 1508 | } | ||
| 1509 | |||
| 1510 | (name, labels) | ||
| 1511 | } | ||
| 1477 | } | 1512 | } |
| 1478 | 1513 | ||
| 1479 | impl RoomLikeItem for GenericRoomItem { | 1514 | impl RoomLikeItem for GenericRoomItem { |
| @@ -1534,25 +1569,15 @@ impl ListItem<IambInfo> for GenericRoomItem { | |||
| 1534 | store: &mut ProgramStore, | 1569 | store: &mut ProgramStore, |
| 1535 | ) -> Text<'_> { | 1570 | ) -> Text<'_> { |
| 1536 | let theme = &store.application.settings.theme; | 1571 | let theme = &store.application.settings.theme; |
| 1572 | let order = store.application.settings.tunables.room_labels.as_slice(); | ||
| 1537 | 1573 | ||
| 1538 | let (unreads, name_style, tags_style) = unreads_and_style(&self.unread, &theme.rooms); | 1574 | let (unreads, name_style, tags_style) = unreads_and_style(&self.unread, &theme.rooms); |
| 1539 | let name_style = selected_style(selected, name_style); | 1575 | let name_style = selected_style(selected, name_style); |
| 1540 | let tags_style = selected_style(selected, tags_style); | 1576 | let tags_style = if selected { name_style } else { tags_style }; |
| 1541 | 1577 | ||
| 1542 | let (name, mut labels) = | 1578 | let (name, labels) = self.name_and_labels(name_style, tags_style, order); |
| 1543 | name_and_labels(&self.name, &self.unread, self.membership, name_style, tags_style); | ||
| 1544 | let mut spans = vec![unreads, name]; | 1579 | let mut spans = vec![unreads, name]; |
| 1545 | 1580 | ||
| 1546 | if let Some(label) = self.room_type.text() && | ||
| 1547 | self.room_type_show | ||
| 1548 | { | ||
| 1549 | labels.push(vec![Span::styled(label, tags_style)]); | ||
| 1550 | } | ||
| 1551 | |||
| 1552 | if let Some(tags) = &self.tags { | ||
| 1553 | labels.extend(tags.keys().map(|t| tag_to_span(t, tags_style))); | ||
| 1554 | } | ||
| 1555 | |||
| 1556 | append_tags(labels, &mut spans, tags_style); | 1581 | append_tags(labels, &mut spans, tags_style); |
| 1557 | Text::from(Line::from(spans)) | 1582 | Text::from(Line::from(spans)) |
| 1558 | } | 1583 | } |
| @@ -1904,6 +1929,7 @@ mod tests { | |||
| 1904 | tags: None, | 1929 | tags: None, |
| 1905 | membership: MatrixRoomState::Joined, | 1930 | membership: MatrixRoomState::Joined, |
| 1906 | unread: UnreadInfo::default(), | 1931 | unread: UnreadInfo::default(), |
| 1932 | room_flags: RoomInfoFlags::NONE, | ||
| 1907 | room_type_show: true, | 1933 | room_type_show: true, |
| 1908 | room_type: RoomType::Room, | 1934 | room_type: RoomType::Room, |
| 1909 | section: None, | 1935 | section: None, |
src/worker.rs +12 −3
| @@ -16,6 +16,7 @@ use matrix_sdk::deserialized_responses::RawSyncOrStrippedState; | |||
| 16 | use matrix_sdk::deserialized_responses::{TimelineEvent, TimelineEventKind}; | 16 | use matrix_sdk::deserialized_responses::{TimelineEvent, TimelineEventKind}; |
| 17 | use matrix_sdk::encryption::{BackupDownloadStrategy, EncryptionSettings}; | 17 | use matrix_sdk::encryption::{BackupDownloadStrategy, EncryptionSettings}; |
| 18 | use matrix_sdk::event_handler::Ctx; | 18 | use matrix_sdk::event_handler::Ctx; |
| 19 | use matrix_sdk::notification_settings::RoomNotificationMode; | ||
| 19 | use matrix_sdk::room::RoomMember; | 20 | use matrix_sdk::room::RoomMember; |
| 20 | use matrix_sdk::ruma::OwnedRoomAliasId; | 21 | use matrix_sdk::ruma::OwnedRoomAliasId; |
| 21 | use matrix_sdk::ruma::api::client::filter::{ | 22 | use matrix_sdk::ruma::api::client::filter::{ |
| @@ -749,8 +750,16 @@ async fn refresh_rooms(client: &Client, store: &AsyncProgramStore, first_sync: b | |||
| 749 | let mut aliases = room.alt_aliases(); | 750 | let mut aliases = room.alt_aliases(); |
| 750 | aliases.extend(room.canonical_alias()); | 751 | aliases.extend(room.canonical_alias()); |
| 751 | 752 | ||
| 753 | let mut flags = RoomInfoFlags::NONE; | ||
| 754 | |||
| 755 | match room.notification_mode().await { | ||
| 756 | Some(RoomNotificationMode::MentionsAndKeywordsOnly) => flags |= RoomInfoFlags::CALMED, | ||
| 757 | Some(RoomNotificationMode::Mute) => flags |= RoomInfoFlags::MUTED, | ||
| 758 | _ => (), | ||
| 759 | } | ||
| 760 | |||
| 752 | pinned.push((room.room_id().to_owned(), room.pinned_event_ids().unwrap_or_default())); | 761 | pinned.push((room.room_id().to_owned(), room.pinned_event_ids().unwrap_or_default())); |
| 753 | names_and_tags.push((room.room_id().to_owned(), name, tags, aliases)); | 762 | names_and_tags.push((room.room_id().to_owned(), name, tags, aliases, flags)); |
| 754 | 763 | ||
| 755 | if room.is_direct().await.unwrap_or_default() { | 764 | if room.is_direct().await.unwrap_or_default() { |
| 756 | dms.push(room); | 765 | dms.push(room); |
| @@ -766,8 +775,8 @@ async fn refresh_rooms(client: &Client, store: &AsyncProgramStore, first_sync: b | |||
| 766 | locked.application.sync_info.rooms = rooms; | 775 | locked.application.sync_info.rooms = rooms; |
| 767 | locked.application.sync_info.dms = dms; | 776 | locked.application.sync_info.dms = dms; |
| 768 | 777 | ||
| 769 | for (room_id, name, tags, aliases) in names_and_tags { | 778 | for (room_id, name, tags, aliases, flags) in names_and_tags { |
| 770 | locked.application.set_room_info(room_id, name, tags, aliases); | 779 | locked.application.set_room_info(room_id, name, tags, aliases, flags); |
| 771 | } | 780 | } |
| 772 | 781 | ||
| 773 | for (room_id, pinned_events) in pinned { | 782 | for (room_id, pinned_events) in pinned { |