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) {
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");
}
}

View File

@ -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);

View File

@ -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++;