Let freedesktop notifications expire

fixes #1026
This commit is contained in:
fiaxh 2021-04-07 21:27:50 +02:00
parent 4ce2bd8cd2
commit 332c772fbe

View file

@ -96,9 +96,10 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object {
uint32 replace_id = content_notifications.has_key(conversation) ? content_notifications[conversation] : 0;
HashTable<string, Variant> hash_table = new HashTable<string, Variant>(null, null);
hash_table["image-data"] = yield get_conversation_icon(conversation);
hash_table["desktop-entry"] = new Variant.string(Dino.Application.get_default().get_application_id());
string[] actions = new string[] {"default", "Open conversation"};
try {
uint32 notification_id = dbus_notifications.notify("Dino", replace_id, "", conversation_display_name, body, actions, hash_table, 0);
uint32 notification_id = dbus_notifications.notify("Dino", replace_id, "", conversation_display_name, body, actions, hash_table, -1);
content_notifications[conversation] = notification_id;
add_action_listener(notification_id, "default", () => {
@ -115,9 +116,10 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object {
HashTable<string, Variant> hash_table = new HashTable<string, Variant>(null, null);
hash_table["image-data"] = yield get_conversation_icon(conversation);
hash_table["desktop-entry"] = new Variant.string(Dino.Application.get_default().get_application_id());
string[] actions = new string[] {"default", "Open conversation", "accept", _("Accept"), "deny", _("Deny")};
try {
uint32 notification_id = dbus_notifications.notify("Dino", 0, "", summary, body, actions, hash_table, 0);
uint32 notification_id = dbus_notifications.notify("Dino", 0, "", summary, body, actions, hash_table, -1);
if (!conversation_notifications.has_key(conversation)) {
conversation_notifications[conversation] = new ArrayList<uint32>();
@ -151,8 +153,9 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object {
}
HashTable<string, Variant> hash_table = new HashTable<string, Variant>(null, null);
hash_table["desktop-entry"] = new Variant.string(Dino.Application.get_default().get_application_id());
try {
dbus_notifications.notify("Dino", 0, "im.dino.Dino", summary, body, new string[]{}, hash_table, 0);
dbus_notifications.notify("Dino", 0, "im.dino.Dino", summary, body, new string[]{}, hash_table, -1);
} catch (Error e) {
warning("Failed showing connection error notification: %s", e.message);
}
@ -170,10 +173,11 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object {
HashTable<string, Variant> hash_table = new HashTable<string, Variant>(null, null);
hash_table["image-data"] = yield get_conversation_icon(direct_conversation);
hash_table["desktop-entry"] = new Variant.string(Dino.Application.get_default().get_application_id());
string[] actions = new string[] {"default", "", "reject", _("Reject"), "accept", _("Accept")};
try {
uint32 notification_id = dbus_notifications.notify("Dino", 0, "", summary, body, actions, hash_table, 0);
uint32 notification_id = dbus_notifications.notify("Dino", 0, "", summary, body, actions, hash_table, -1);
Conversation group_conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(room_jid, account, Conversation.Type.GROUPCHAT);
add_action_listener(notification_id, "default", () => {
@ -202,10 +206,11 @@ public class Dino.Ui.FreeDesktopNotifier : NotificationProvider, Object {
HashTable<string, Variant> hash_table = new HashTable<string, Variant>(null, null);
hash_table["image-data"] = yield get_conversation_icon(conversation);
hash_table["desktop-entry"] = new Variant.string(Dino.Application.get_default().get_application_id());
string[] actions = new string[] {"deny", _("Deny"), "accept", _("Accept")};
try {
uint32 notification_id = dbus_notifications.notify("Dino", 0, "", summary, body, actions, hash_table, 0);
uint32 notification_id = dbus_notifications.notify("Dino", 0, "", summary, body, actions, hash_table, -1);
add_action_listener(notification_id, "accept", () => {
GLib.Application.get_default().activate_action("accept-voice-request", new Variant.int32(conversation.id));