Fix how highlights are handled

This commit is contained in:
Pavel Djundik 2016-02-23 12:38:51 +02:00
parent b53e5c407c
commit 357e238a45
5 changed files with 19 additions and 27 deletions

View file

@ -640,10 +640,7 @@ $(function() {
chat.on("msg", ".messages", function(e, target, msg) {
var button = sidebar.find(".chan[data-target='" + target + "']");
var isQuery = button.hasClass("query");
var type = msg.type;
var highlight = type.contains("highlight");
var message = type.contains("message");
if (highlight || isQuery || (options.notifyAllMessages && message)) {
if (msg.highlight || isQuery || (options.notifyAllMessages && msg.type === "message")) {
if (!document.hasFocus() || !$(target).hasClass("active")) {
if (options.notification) {
pop.play();
@ -679,7 +676,7 @@ $(function() {
"nick",
"mode",
];
if ($.inArray(type, ignore) !== -1){
if ($.inArray(msg.type, ignore) !== -1){
return;
}
@ -688,7 +685,7 @@ $(function() {
var i = (badge.data("count") || 0) + 1;
badge.data("count", i);
badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i);
if (highlight || isQuery) {
if (msg.highlight || isQuery) {
badge.addClass("highlight");
}
}

View file

@ -1,4 +1,4 @@
<div class="msg {{type}} {{#if self}}self{{/if}}">
<div class="msg {{type}}{{#if self}} self{{/if}}{{#if highlight}} highlight{{/if}}">
<span class="time">
{{tz time}}
</span>

View file

@ -1,4 +1,4 @@
<div class="msg {{type}} {{#if self}}self{{/if}}">
<div class="msg {{type}}{{#if self}} self{{/if}}{{#if highlight}} highlight{{/if}}">
<span class="time">
{{tz time}}
</span>

View file

@ -1,11 +1,8 @@
var Msg = require("../../models/msg");
module.exports = function(network, chan, cmd, args) {
if (cmd !== "slap" && cmd !== "me") {
return;
}
var client = this;
var irc = network.irc;
switch (cmd) {
@ -22,17 +19,10 @@ module.exports = function(network, chan, cmd, args) {
chan.name,
text
);
var msg = new Msg({
type: Msg.Type.ACTION,
mode: chan.getMode(irc.me),
irc.emit("message", {
from: irc.me,
text: text
});
chan.messages.push(msg);
client.emit("msg", {
chan: chan.id,
msg: msg
to: chan.name,
message: "\u0001ACTION " + text
});
break;
}

View file

@ -28,15 +28,19 @@ module.exports = function(irc, network) {
});
}
var type = "";
var type = Msg.Type.MESSAGE;
var text = data.message;
if (text.split(" ")[0] === "\u0001ACTION") {
var textSplit = text.split(" ");
if (textSplit[0] === "\u0001ACTION") {
type = Msg.Type.ACTION;
text = text.replace(/^\u0001ACTION|\u0001$/g, "");
}
text.split(" ").forEach(function(w) {
if (w.replace(/^@/, "").toLowerCase().indexOf(irc.me.toLowerCase()) === 0) type += " highlight";
var highlight = false;
textSplit.forEach(function(w) {
if (w.replace(/^@/, "").toLowerCase().indexOf(irc.me.toLowerCase()) === 0) {
highlight = true;
}
});
var self = false;
@ -50,11 +54,12 @@ module.exports = function(irc, network) {
var name = data.from;
var msg = new Msg({
type: type || Msg.Type.MESSAGE,
type: type,
mode: chan.getMode(name),
from: name,
text: text,
self: self
self: self,
highlight: highlight
});
chan.messages.push(msg);
client.emit("msg", {