aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/notifications.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-05-30 22:31:05 +0200
committerfiaxh <git@mx.ax.lt>2017-05-30 22:33:33 +0200
commit387433ebb9bab442502f812e0364111f37270bcb (patch)
tree5dba69992da0a402380d7bde27433c750f5be920 /main/src/ui/notifications.vala
parent3a8df2069eba3a5a4174749fc46a6698c1877ec1 (diff)
downloaddino-387433ebb9bab442502f812e0364111f37270bcb.tar.gz
dino-387433ebb9bab442502f812e0364111f37270bcb.zip
Notifications + typing notifications + message marker settings per conversation
Diffstat (limited to 'main/src/ui/notifications.vala')
-rw-r--r--main/src/ui/notifications.vala12
1 files changed, 11 insertions, 1 deletions
diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala
index e5eda271..32e8d7ad 100644
--- a/main/src/ui/notifications.vala
+++ b/main/src/ui/notifications.vala
@@ -31,6 +31,8 @@ public class Notifications : Object {
}
private void on_message_received(Entities.Message message, Conversation conversation) {
+ if (!should_notify_message(message, conversation)) return;
+
if (!notifications.has_key(conversation)) {
notifications[conversation] = new Notify.Notification("", null, null);
notifications[conversation].set_hint("transient", true);
@@ -74,7 +76,7 @@ public class Notifications : Object {
AddConversation.Chat.AddContactDialog dialog = new AddConversation.Chat.AddContactDialog(stream_interactor);
dialog.jid = jid.bare_jid.to_string();
dialog.account = account;
- dialog.show();
+ dialog.present();
}
try {
notification.close();
@@ -90,6 +92,14 @@ public class Notifications : Object {
notification.show();
} catch (Error error) { }
}
+
+ private bool should_notify_message(Entities.Message message, Conversation conversation) {
+ Conversation.NotifySetting notify = conversation.get_notification_setting(stream_interactor);
+ if (notify == Conversation.NotifySetting.OFF) return false;
+ string? nick = stream_interactor.get_module(MucManager.IDENTITY).get_nick(conversation.counterpart, conversation.account);
+ if (notify == Conversation.NotifySetting.HIGHLIGHT && nick != null && !message.body.contains(nick)) return false;
+ return true;
+ }
}
} \ No newline at end of file