From e0de712c046fb7910edf0a12cada8144b109664c Mon Sep 17 00:00:00 2001 From: bleakgrey Date: Tue, 17 Apr 2018 15:10:57 +0300 Subject: [PATCH] Implement notification dismiss --- src/Views/NotificationsView.vala | 2 ++ src/Widgets/NotificationWidget.vala | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Views/NotificationsView.vala b/src/Views/NotificationsView.vala index 7385a29..2c2722b 100644 --- a/src/Views/NotificationsView.vala +++ b/src/Views/NotificationsView.vala @@ -64,5 +64,7 @@ public class Tootle.NotificationsView : Tootle.AbstractView { } }); } + + } diff --git a/src/Widgets/NotificationWidget.vala b/src/Widgets/NotificationWidget.vala index 72c7a73..1e72240 100644 --- a/src/Widgets/NotificationWidget.vala +++ b/src/Widgets/NotificationWidget.vala @@ -22,6 +22,11 @@ public class Tootle.NotificationWidget : Gtk.Grid { label.use_markup = true; dismiss = new Gtk.Button.from_icon_name ("close-symbolic", Gtk.IconSize.SMALL_TOOLBAR); dismiss.tooltip_text = _("Dismiss"); + dismiss.clicked.connect (() => { + var parent = this.get_parent () as Gtk.Box; + parent.remove (this); + dismiss_notification (this.notification); + }); attach(image, 0, 0, 1, 1); attach(label, 1, 0, 1, 1); @@ -41,5 +46,15 @@ public class Tootle.NotificationWidget : Gtk.Grid { attach(status_widget, 0, 1, 3, 1); } } + + public static Soup.Message dismiss_notification (Notification notification){ + var url = Settings.instance.instance_url; + url += "api/v1/notifications/dismiss"; + url += "?id=" + notification.id.to_string (); + + var msg = new Soup.Message("POST", url); + NetManager.instance.queue(msg, (sess, mess) => {}); + return msg; + } }