diff --git a/client/js/lounge.js b/client/js/lounge.js index 15d86460..53ce7ec2 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -184,7 +184,18 @@ $(function() { channel.channel.unread = 0; } - if (sidebar.find(".highlight").length === 0) { + let hasAnyHighlights = false; + + for (const network of vueApp.networks) { + for (const channel of network.channels) { + if (channel.highlight > 0) { + hasAnyHighlights = true; + break; + } + } + } + + if (!hasAnyHighlights) { utils.toggleNotificationMarkers(false); } @@ -290,9 +301,15 @@ $(function() { }); $(document).on("visibilitychange focus click", () => { - if (sidebar.find(".highlight").length === 0) { - utils.toggleNotificationMarkers(false); + for (const network of vueApp.networks) { + for (const channel of network.channels) { + if (channel.highlight > 0) { + return; + } + } } + + utils.toggleNotificationMarkers(false); }); // Compute how many milliseconds are remaining until the next day starts diff --git a/client/js/render.js b/client/js/render.js index 547d32cc..395c7270 100644 --- a/client/js/render.js +++ b/client/js/render.js @@ -11,6 +11,7 @@ const JoinChannel = require("./join-channel"); const helpers_parse = require("./libs/handlebars/parse"); const Userlist = require("./userlist"); const storage = require("./localStorage"); +const {vueApp} = require("./vue"); const chat = $("#chat"); const sidebar = $("#sidebar"); @@ -280,8 +281,14 @@ function renderNetworks(data, singleNetwork) { utils.confirmExit(); - if (sidebar.find(".highlight").length) { - utils.toggleNotificationMarkers(true); + for (const network of vueApp.networks) { + for (const channel of network.channels) { + if (channel.highlight > 0) { + utils.updateTitle(); + utils.toggleNotificationMarkers(true); + return; + } + } } } diff --git a/client/js/socket-events/msg.js b/client/js/socket-events/msg.js index f1e63540..ab031a63 100644 --- a/client/js/socket-events/msg.js +++ b/client/js/socket-events/msg.js @@ -5,7 +5,6 @@ const socket = require("../socket"); const render = require("../render"); const utils = require("../utils"); const options = require("../options"); -const helpers_roundBadgeNumber = require("../libs/handlebars/roundBadgeNumber"); const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage"); const webpush = require("../webpush"); const chat = $("#chat"); @@ -34,11 +33,10 @@ function processReceivedMessage(data) { let channelContainer = chat.find(target); let channel = findChannel(data.chan); - // Clear unread/highlight counter if self-message - if (data.msg.self) { - channel.channel.highlight = 0; - channel.channel.unread = 0; + channel.channel.highlight = data.highlight; + channel.channel.unread = data.unread; + if (data.msg.self || data.msg.highlight) { utils.updateTitle(); } @@ -207,18 +205,4 @@ function notifyMessage(targetId, channel, msg) { } } } - - if (!serverUnread || button.hasClass("active")) { - return; - } - - const badge = button.find(".badge") - .attr("data-highlight", serverHighlight) - .html(helpers_roundBadgeNumber(serverUnread)); - - if (msg.highlight) { - badge.addClass("highlight"); - - utils.updateTitle(); - } }