push: Add convenience methods to check if an action triggers a notification or a sound

This commit is contained in:
Kévin Commaille 2023-03-13 13:54:22 +01:00
parent b6717bc2ea
commit a399a4017a
No known key found for this signature in database
GPG Key ID: DD507DAE96E8245C

View File

@ -35,6 +35,19 @@ impl Action {
pub fn is_highlight(&self) -> bool {
matches!(self, Action::SetTweak(Tweak::Highlight(true)))
}
/// Whether this action should trigger a notification.
pub fn should_notify(&self) -> bool {
matches!(self, Action::Notify | Action::Coalesce)
}
/// The sound that should be played with this action, if any.
pub fn sound(&self) -> Option<&str> {
match self {
Action::SetTweak(Tweak::Sound(sound)) => Some(sound),
_ => None,
}
}
}
/// The `set_tweak` action.