From 91aa4c6c4aadc80ad0884753e304353f7c95377a Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Fri, 22 Apr 2016 19:38:59 +0300 Subject: [PATCH] Never highlight self messages in queries, and leave it up to the server to decide --- client/js/lounge.js | 7 +++---- src/plugins/irc-events/invite.js | 1 + src/plugins/irc-events/message.js | 15 ++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 49bb54ae..6aea2b20 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -761,8 +761,7 @@ $(function() { chat.on("msg", ".messages", function(e, target, msg) { var button = sidebar.find(".chan[data-target='" + target + "']"); - var isQuery = button.hasClass("query"); - if (msg.type === "invite" || msg.highlight || isQuery || (options.notifyAllMessages && msg.type === "message")) { + if (msg.highlight || (options.notifyAllMessages && msg.type === "message")) { if (!document.hasFocus() || !$(target).hasClass("active")) { if (options.notification) { pop.play(); @@ -778,7 +777,7 @@ $(function() { body = msg.from + " invited you to " + msg.channel; } else { title = msg.from; - if (!isQuery) { + if (!button.hasClass("query")) { title += " (" + button.data("title").trim() + ")"; } title += " says:"; @@ -823,7 +822,7 @@ $(function() { var i = (badge.data("count") || 0) + 1; badge.data("count", i); badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i); - if (msg.highlight || isQuery) { + if (msg.highlight) { badge.addClass("highlight"); } } diff --git a/src/plugins/irc-events/invite.js b/src/plugins/irc-events/invite.js index 7accbb7c..711d6d7d 100644 --- a/src/plugins/irc-events/invite.js +++ b/src/plugins/irc-events/invite.js @@ -14,6 +14,7 @@ module.exports = function(irc, network) { from: data.nick, invited: data.invited, channel: data.channel, + highlight: true, invitedYou: data.invited === irc.user.nick }); chan.messages.push(msg); diff --git a/src/plugins/irc-events/message.js b/src/plugins/irc-events/message.js index 53cda20b..4e3332c7 100644 --- a/src/plugins/irc-events/message.js +++ b/src/plugins/irc-events/message.js @@ -28,6 +28,9 @@ module.exports = function(irc, network) { }); function handleMessage(data) { + var highlight = false; + var self = data.nick === irc.user.nick; + // Server messages go to server window, no questions asked if (data.from_server) { chan = network.channels[0]; @@ -45,6 +48,7 @@ module.exports = function(irc, network) { if (data.type === Msg.Type.NOTICE) { chan = network.channels[0]; } else { + highlight = !self; chan = new Chan({ type: Chan.Type.QUERY, name: target @@ -58,13 +62,14 @@ module.exports = function(irc, network) { } } - var self = data.nick === irc.user.nick; - + // Query messages (unless self) always highlight // Self messages are never highlighted // Non-self messages are highlighted as soon as the nick is detected - var highlight = !self && data.message.split(" ").some(function(w) { - return (w.replace(/^@/, "").toLowerCase().indexOf(irc.user.nick.toLowerCase()) === 0); - }); + if (!highlight && !self) { + highlight = data.message.split(" ").some(function(w) { + return (w.replace(/^@/, "").toLowerCase().indexOf(irc.user.nick.toLowerCase()) === 0); + }); + } if (chan.id !== client.activeChannel) { chan.unread++;