Remove remaining DOM references to badge/highlight

This commit is contained in:
Pavel Djundik 2018-07-08 12:09:33 +03:00 committed by Pavel Djundik
parent 631fd6138c
commit 0b269423aa
3 changed files with 32 additions and 24 deletions

View File

@ -184,7 +184,18 @@ $(function() {
channel.channel.unread = 0; 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); utils.toggleNotificationMarkers(false);
} }
@ -290,9 +301,15 @@ $(function() {
}); });
$(document).on("visibilitychange focus click", () => { $(document).on("visibilitychange focus click", () => {
if (sidebar.find(".highlight").length === 0) { for (const network of vueApp.networks) {
utils.toggleNotificationMarkers(false); 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 // Compute how many milliseconds are remaining until the next day starts

View File

@ -11,6 +11,7 @@ const JoinChannel = require("./join-channel");
const helpers_parse = require("./libs/handlebars/parse"); const helpers_parse = require("./libs/handlebars/parse");
const Userlist = require("./userlist"); const Userlist = require("./userlist");
const storage = require("./localStorage"); const storage = require("./localStorage");
const {vueApp} = require("./vue");
const chat = $("#chat"); const chat = $("#chat");
const sidebar = $("#sidebar"); const sidebar = $("#sidebar");
@ -280,8 +281,14 @@ function renderNetworks(data, singleNetwork) {
utils.confirmExit(); utils.confirmExit();
if (sidebar.find(".highlight").length) { for (const network of vueApp.networks) {
utils.toggleNotificationMarkers(true); for (const channel of network.channels) {
if (channel.highlight > 0) {
utils.updateTitle();
utils.toggleNotificationMarkers(true);
return;
}
}
} }
} }

View File

@ -5,7 +5,6 @@ const socket = require("../socket");
const render = require("../render"); const render = require("../render");
const utils = require("../utils"); const utils = require("../utils");
const options = require("../options"); const options = require("../options");
const helpers_roundBadgeNumber = require("../libs/handlebars/roundBadgeNumber");
const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage"); const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage");
const webpush = require("../webpush"); const webpush = require("../webpush");
const chat = $("#chat"); const chat = $("#chat");
@ -34,11 +33,10 @@ function processReceivedMessage(data) {
let channelContainer = chat.find(target); let channelContainer = chat.find(target);
let channel = findChannel(data.chan); let channel = findChannel(data.chan);
// Clear unread/highlight counter if self-message channel.channel.highlight = data.highlight;
if (data.msg.self) { channel.channel.unread = data.unread;
channel.channel.highlight = 0;
channel.channel.unread = 0;
if (data.msg.self || data.msg.highlight) {
utils.updateTitle(); 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();
}
} }