Merge branch 'notification-title' into 'master'

display the group name in notifications

See merge request Schmiddiii/flare!35
This commit is contained in:
Julian Schmidhuber committed 2023-03-16 15:19:34 +00:00
commit 0d0563a40b
2 files changed
+19 -3

No files matched your search

+4
View File
@@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated all dependencies
### Changed
- Notifications for group messages now display the name of the group instead of just the name of the sender.
## [0.6.0] - 2023-01-13
### Added
+15 -3
View File
@@ -10,14 +10,26 @@ glib::wrapper! {
impl DisplayMessage {
pub fn send_notification(&self) {
let sender = self.sender();
let channel = self.channel();
let body = self.textual_description();
if sender.is_self() || body.is_none() || body.as_ref().unwrap().is_empty() {
// Skip notifications for messages sent from self or empty messages.
return;
}
let notification = gio::Notification::new(&sender.title());
notification.set_body(body.as_deref());
let notification_title;
let notification_body;
if channel.group_context().is_some() {
notification_title = channel.title().to_string();
notification_body = format!("{}: {}",
sender.title().to_string(),
body.as_ref().unwrap().to_string());
}
else {
notification_title = sender.title().to_string();
notification_body = body.as_ref().unwrap().to_string();
}
let notification = gio::Notification::new(&notification_title);
notification.set_body(Some(&notification_body));
let icon = Pixbuf::from_resource("/icon.png").expect("Flare to have an application icon");
notification.set_icon(&icon);