tootle-linux-client/src/Views/Notifications.vala

48 lines
1.2 KiB
Vala
Raw Normal View History

2018-04-17 14:01:55 +02:00
using Gtk;
using Gdk;
2021-07-23 13:41:03 +02:00
public class Tootle.Views.Notifications : Views.Timeline, AccountHolder, Streamable {
protected InstanceAccount? last_account = null;
//FIXME: Display unread dot
public Notifications () {
Object (
url: "/api/v1/notifications",
label: _("Notifications"),
icon: "bell-symbolic"
);
accepts = typeof (API.Notification);
}
public override void on_account_changed (InstanceAccount? acc) {
base.on_account_changed (acc);
if (last_account != null) {
last_account.notification_inhibitors.remove (this);
acc.stream_event[InstanceAccount.EVENT_NOTIFICATION].disconnect (on_new_post);
2020-05-29 14:19:35 +02:00
}
2020-05-30 12:31:02 +02:00
2021-07-23 13:41:03 +02:00
last_account = acc;
acc.stream_event[InstanceAccount.EVENT_NOTIFICATION].connect (on_new_post);
}
2019-03-11 15:14:37 +01:00
2021-07-23 13:41:03 +02:00
public override void on_shown () {
base.on_shown ();
if (account != null) {
if (!account.notification_inhibitors.contains (this))
account.notification_inhibitors.add (this);
2020-05-31 12:28:35 +02:00
2021-07-23 13:41:03 +02:00
account.read_notifications (account.last_received_id);
}
}
public override void on_hidden () {
base.on_hidden ();
if (account != null) {
if (account.notification_inhibitors.contains (this))
account.notification_inhibitors.remove (this);
}
}
2018-04-17 14:01:55 +02:00
}