Skip to content

Commit

Permalink
Fix notifications in query windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed May 14, 2016
1 parent 7005034 commit dd2102a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions client/js/lounge.js
Expand Up @@ -213,6 +213,10 @@ $(function() {
target = "#chan-" + chat.find(".active").data("id");
}

// Modifying data.msg.highlight directly breaks notifications, as
// everything is passed by instance in javascript, not by value
data.msg.shouldHighlight = data.msg.highlight && data.msg.chanType !== "query";

var chan = chat.find(target);
var msg;

Expand Down Expand Up @@ -803,7 +807,7 @@ $(function() {
body = msg.from + " invited you to " + msg.channel;
} else {
title = msg.from;
if (!button.hasClass("query")) {
if (msg.chanType !== "query") {
title += " (" + button.data("title").trim() + ")";
}
title += " says:";
Expand All @@ -827,8 +831,7 @@ $(function() {
}
}

button = button.filter(":not(.active)");
if (button.length === 0) {
if (button.hasClass("active")) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion client/views/msg.tpl
@@ -1,4 +1,4 @@
<div class="msg {{type}}{{#if self}} self{{/if}}{{#if highlight}} highlight{{/if}}">
<div class="msg {{type}}{{#if self}} self{{/if}}{{#if shouldHighlight}} highlight{{/if}}">
<span class="time">
{{tz time}}
</span>
Expand Down
2 changes: 1 addition & 1 deletion client/views/msg_action.tpl
@@ -1,4 +1,4 @@
<div class="msg {{type}}{{#if self}} self{{/if}}{{#if highlight}} highlight{{/if}}">
<div class="msg {{type}}{{#if self}} self{{/if}}{{#if shouldHighlight}} highlight{{/if}}">
<span class="time">
{{tz time}}
</span>
Expand Down
10 changes: 7 additions & 3 deletions src/plugins/irc-events/message.js
Expand Up @@ -46,7 +46,6 @@ 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
Expand All @@ -58,10 +57,14 @@ module.exports = function(irc, network) {
});
}
}

// Query messages (unless self) always highlight
if (chan.type === Chan.Type.QUERY) {
highlight = !self;
}
}

// Query messages (unless self) always highlight
// Self messages are never highlighted
// Self messages in channels are never highlighted
// Non-self messages are highlighted as soon as the nick is detected
if (!highlight && !self) {
highlight = network.highlightRegex.test(data.message);
Expand All @@ -76,6 +79,7 @@ module.exports = function(irc, network) {
}

var msg = new Msg({
chanType: chan.type,
type: data.type,
time: data.time,
mode: chan.getMode(data.nick),
Expand Down

0 comments on commit dd2102a

Please sign in to comment.