Never highlight self messages in queries, and leave it up to the server to decide

This commit is contained in:
Pavel Djundik 2016-04-22 19:38:59 +03:00
parent 84685acdcd
commit 91aa4c6c4a
3 changed files with 14 additions and 9 deletions

View File

@ -761,8 +761,7 @@ $(function() {
chat.on("msg", ".messages", function(e, target, msg) { chat.on("msg", ".messages", function(e, target, msg) {
var button = sidebar.find(".chan[data-target='" + target + "']"); var button = sidebar.find(".chan[data-target='" + target + "']");
var isQuery = button.hasClass("query"); if (msg.highlight || (options.notifyAllMessages && msg.type === "message")) {
if (msg.type === "invite" || msg.highlight || isQuery || (options.notifyAllMessages && msg.type === "message")) {
if (!document.hasFocus() || !$(target).hasClass("active")) { if (!document.hasFocus() || !$(target).hasClass("active")) {
if (options.notification) { if (options.notification) {
pop.play(); pop.play();
@ -778,7 +777,7 @@ $(function() {
body = msg.from + " invited you to " + msg.channel; body = msg.from + " invited you to " + msg.channel;
} else { } else {
title = msg.from; title = msg.from;
if (!isQuery) { if (!button.hasClass("query")) {
title += " (" + button.data("title").trim() + ")"; title += " (" + button.data("title").trim() + ")";
} }
title += " says:"; title += " says:";
@ -823,7 +822,7 @@ $(function() {
var i = (badge.data("count") || 0) + 1; var i = (badge.data("count") || 0) + 1;
badge.data("count", i); badge.data("count", i);
badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i); badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i);
if (msg.highlight || isQuery) { if (msg.highlight) {
badge.addClass("highlight"); badge.addClass("highlight");
} }
} }

View File

@ -14,6 +14,7 @@ module.exports = function(irc, network) {
from: data.nick, from: data.nick,
invited: data.invited, invited: data.invited,
channel: data.channel, channel: data.channel,
highlight: true,
invitedYou: data.invited === irc.user.nick invitedYou: data.invited === irc.user.nick
}); });
chan.messages.push(msg); chan.messages.push(msg);

View File

@ -28,6 +28,9 @@ module.exports = function(irc, network) {
}); });
function handleMessage(data) { function handleMessage(data) {
var highlight = false;
var self = data.nick === irc.user.nick;
// Server messages go to server window, no questions asked // Server messages go to server window, no questions asked
if (data.from_server) { if (data.from_server) {
chan = network.channels[0]; chan = network.channels[0];
@ -45,6 +48,7 @@ module.exports = function(irc, network) {
if (data.type === Msg.Type.NOTICE) { if (data.type === Msg.Type.NOTICE) {
chan = network.channels[0]; chan = network.channels[0];
} else { } else {
highlight = !self;
chan = new Chan({ chan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,
name: target 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 // Self messages are never highlighted
// Non-self messages are highlighted as soon as the nick is detected // Non-self messages are highlighted as soon as the nick is detected
var highlight = !self && data.message.split(" ").some(function(w) { if (!highlight && !self) {
return (w.replace(/^@/, "").toLowerCase().indexOf(irc.user.nick.toLowerCase()) === 0); highlight = data.message.split(" ").some(function(w) {
}); return (w.replace(/^@/, "").toLowerCase().indexOf(irc.user.nick.toLowerCase()) === 0);
});
}
if (chan.id !== client.activeChannel) { if (chan.id !== client.activeChannel) {
chan.unread++; chan.unread++;