Remove jquery from msg event

This commit is contained in:
Pavel Djundik 2019-11-04 12:46:18 +02:00
parent 6b8fea8afc
commit 8972242863
1 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,5 @@
"use strict"; "use strict";
const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage"); const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage");
const webpush = require("../webpush"); const webpush = require("../webpush");
@ -14,7 +13,7 @@ try {
pop.src = "audio/pop.wav"; pop.src = "audio/pop.wav";
} catch (e) { } catch (e) {
pop = { pop = {
play: $.noop, play() {},
}; };
} }
@ -96,8 +95,6 @@ socket.on("msg", function(data) {
}); });
function notifyMessage(targetId, channel, activeChannel, msg) { function notifyMessage(targetId, channel, activeChannel, msg) {
const button = $("#sidebar .chan[data-id='" + targetId + "']");
if (msg.highlight || (store.state.settings.notifyAllMessages && msg.type === "message")) { if (msg.highlight || (store.state.settings.notifyAllMessages && msg.type === "message")) {
if (!document.hasFocus() || !activeChannel || activeChannel.channel !== channel) { if (!document.hasFocus() || !activeChannel || activeChannel.channel !== channel) {
if (store.state.settings.notification) { if (store.state.settings.notification) {
@ -155,9 +152,16 @@ function notifyMessage(targetId, channel, activeChannel, msg) {
timestamp: timestamp, timestamp: timestamp,
}); });
notify.addEventListener("click", function() { notify.addEventListener("click", function() {
window.focus();
button.trigger("click");
this.close(); this.close();
window.focus();
const channelTarget = document.querySelector(
"#sidebar .chan[data-id='" + targetId + "']"
);
if (channelTarget) {
channelTarget.click();
}
}); });
} }
} catch (exception) { } catch (exception) {