mirror of
https://gitlab.com/schmiddi-on-mobile/flare.git
synced 2026-10-28 22:47:47 -04:00
Merge branch 'notification-title' into 'master'
display the group name in notifications See merge request Schmiddiii/flare!35
This commit is contained in:
commit
0d0563a40b
2 files changed
+19
-3
No files matched your search
@@ -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
|
||||
|
||||
@@ -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(¬ification_title);
|
||||
notification.set_body(Some(¬ification_body));
|
||||
let icon = Pixbuf::from_resource("/icon.png").expect("Flare to have an application icon");
|
||||
notification.set_icon(&icon);
|
||||
|
||||
|
||||
Reference in new issue
Block a user