Do not trigger a DOM event on every message

This commit is contained in:
Pavel Djundik 2016-10-01 13:09:57 +03:00
parent 52a0552bc4
commit 743d4b61d5

View File

@ -352,17 +352,14 @@ $(function() {
var target = "#chan-" + data.chan; var target = "#chan-" + data.chan;
var container = chat.find(target + " .messages"); var container = chat.find(target + " .messages");
container container.append(msg);
.append(msg)
.trigger("msg", [
target,
data.msg
]);
if (data.msg.self) { if (data.msg.self) {
container container
.find(".unread-marker") .find(".unread-marker")
.appendTo(container); .appendTo(container);
} else {
chatMessageShown(target, data.msg);
} }
}); });
@ -892,11 +889,7 @@ $(function() {
}); });
}); });
chat.on("msg", ".messages", function(e, target, msg) { function chatMessageShown(target, msg) {
if (msg.self) {
return;
}
var button = sidebar.find(".chan[data-target='" + target + "']"); var button = sidebar.find(".chan[data-target='" + target + "']");
if (msg.highlight || (options.notifyAllMessages && msg.type === "message")) { if (msg.highlight || (options.notifyAllMessages && msg.type === "message")) {
if (!document.hasFocus() || !$(target).hasClass("active")) { if (!document.hasFocus() || !$(target).hasClass("active")) {
@ -960,7 +953,7 @@ $(function() {
badge.addClass("highlight"); badge.addClass("highlight");
} }
} }
}); }
chat.on("click", ".show-more-button", function() { chat.on("click", ".show-more-button", function() {
var self = $(this); var self = $(this);