Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions crates/matrix-sdk-ui/src/notification_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,10 @@ pub struct NotificationItem {
/// Is the room a space?
pub is_space: bool,

/// Is it a noisy notification? (i.e. does any push action contain a sound
/// action)
/// Is it a noisy notification?
///
/// Notifications are considered noisy when their push actions notify. If a
/// sound tweak is present, it is treated as noisy as well.
///
/// It is set if and only if the push actions could be determined.
pub is_noisy: Option<bool>,
Expand Down Expand Up @@ -1019,7 +1021,12 @@ impl NotificationItem {
}
}

let is_noisy = push_actions.map(|actions| actions.iter().any(|a| a.sound().is_some()));
// Treat notify actions as noisy by default, even when servers don't
// include an explicit sound tweak in the matching rule.
let is_noisy = push_actions.map(|actions| {
actions.iter().any(Action::should_notify)
|| actions.iter().any(|action| action.sound().is_some())
});
let has_mention = push_actions.map(|actions| actions.iter().any(|a| a.is_highlight()));
let thread_id = event.thread_id().clone();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ async fn test_notification_client_sliding_sync() {
assert_eq!(item.sender_display_name.as_deref(), Some(sender_display_name));
assert_eq!(item.sender_avatar_url, Some(sender_avatar_url.to_string()));
assert_eq!(item.room_computed_display_name, sender_display_name);
assert_eq!(item.is_noisy, Some(false));
assert_eq!(item.is_noisy, Some(true));
}

#[async_test]
Expand Down Expand Up @@ -669,7 +669,7 @@ async fn test_notification_client_sliding_sync_invites() {
assert_eq!(item.sender_display_name.as_deref(), Some(sender_display_name));
assert_eq!(item.sender_avatar_url, Some(sender_avatar_url.to_string()));
assert_eq!(item.room_computed_display_name, sender_display_name);
assert_eq!(item.is_noisy, Some(false));
assert_eq!(item.is_noisy, Some(true));
}

#[async_test]
Expand Down Expand Up @@ -813,7 +813,7 @@ async fn test_notification_client_sliding_sync_invites_with_event_id() {
assert_eq!(item.sender_display_name.as_deref(), Some(sender_display_name));
assert_eq!(item.sender_avatar_url, Some(sender_avatar_url.to_string()));
assert_eq!(item.room_computed_display_name, sender_display_name);
assert_eq!(item.is_noisy, Some(false));
assert_eq!(item.is_noisy, Some(true));
}

#[async_test]
Expand Down Expand Up @@ -1008,7 +1008,7 @@ async fn test_notification_client_mixed() {
assert_eq!(item.sender_display_name.as_deref(), Some(sender_display_name));
assert_eq!(item.sender_avatar_url, Some(sender_avatar_url.to_string()));
assert_eq!(item.room_computed_display_name, sender_display_name);
assert_eq!(item.is_noisy, Some(false));
assert_eq!(item.is_noisy, Some(true));
}

#[async_test]
Expand Down
Loading