From cc26b7ff0f876ea9f44e4ec1d452d12a17b43610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 29 Feb 2016 07:25:40 +0000 Subject: [PATCH] Add notifications for channel invites --- client/js/lounge.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index d62c2b02..413e5b21 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -682,21 +682,31 @@ $(function() { chat.on("msg", ".messages", function(e, target, msg) { var button = sidebar.find(".chan[data-target='" + target + "']"); var isQuery = button.hasClass("query"); - if (msg.highlight || isQuery || (options.notifyAllMessages && msg.type === "message")) { + if (msg.type === "invite" || msg.highlight || isQuery || (options.notifyAllMessages && msg.type === "message")) { if (!document.hasFocus() || !$(target).hasClass("active")) { if (options.notification) { pop.play(); } toggleFaviconNotification(true); + if (options.badge && Notification.permission === "granted") { - var title = msg.from; - if (!isQuery) { - title += " (" + button.text().trim() + ")"; + var title; + var body; + + if (msg.type === "invite") { + title = "New channel invite:"; + body = msg.from + " invited you to " + msg.text; + } else { + title = msg.from; + if (!isQuery) { + title += " (" + button.text().trim() + ")"; + } + title += " says:"; + body = msg.text.trim(); } - title += " says:"; var notify = new Notification(title, { - body: msg.text.trim(), + body: body, icon: "img/logo-64.png", tag: target });