From d00cf72614d2d8f1fef3437b28e7cc111d156468 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 21 Jun 2018 16:51:07 +0300 Subject: [PATCH] Reset highlights on self messages; update title when other client opens a channel --- client/js/socket-events/msg.js | 15 ++++++++++----- client/js/socket-events/open.js | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/js/socket-events/msg.js b/client/js/socket-events/msg.js index f83755d4..ad0b19e0 100644 --- a/client/js/socket-events/msg.js +++ b/client/js/socket-events/msg.js @@ -97,7 +97,12 @@ function processReceivedMessage(data) { // Clear unread/highlight counter if self-message if (data.msg.self) { - sidebarTarget.find(".badge").removeClass("highlight").empty(); + sidebarTarget.find(".badge") + .attr("data-highlight", 0) + .removeClass("highlight") + .empty(); + + utils.updateTitle(); } let messageLimit = 0; @@ -211,12 +216,12 @@ function notifyMessage(targetId, channel, msg) { return; } - const badge = button.find(".badge").html(helpers_roundBadgeNumber(serverUnread)); + const badge = button.find(".badge") + .attr("data-highlight", serverHighlight) + .html(helpers_roundBadgeNumber(serverUnread)); if (msg.highlight) { - badge - .attr("data-highlight", serverHighlight) - .addClass("highlight"); + badge.addClass("highlight"); utils.updateTitle(); } diff --git a/client/js/socket-events/open.js b/client/js/socket-events/open.js index 07368158..88833c95 100644 --- a/client/js/socket-events/open.js +++ b/client/js/socket-events/open.js @@ -2,6 +2,7 @@ const $ = require("jquery"); const socket = require("../socket"); +const utils = require("../utils"); // Sync unread badge and marker when other clients open a channel socket.on("open", function(id) { @@ -22,6 +23,8 @@ socket.on("open", function(id) { .removeClass("highlight") .empty(); + utils.updateTitle(); + // Move unread marker to the bottom channel .find(".unread-marker")