Merge pull request #2496 from Jay2k1/alert-count-in-title
Add alert count to title
This commit is contained in:
commit
25e26a5b28
@ -225,21 +225,13 @@ $(function() {
|
|||||||
.trigger("show");
|
.trigger("show");
|
||||||
|
|
||||||
utils.togglePreviewMoreButtonsIfNeeded();
|
utils.togglePreviewMoreButtonsIfNeeded();
|
||||||
|
utils.updateTitle();
|
||||||
let title = $(document.body).data("app-name");
|
|
||||||
const chanTitle = chan.attr("aria-label");
|
|
||||||
|
|
||||||
if (chanTitle.length > 0) {
|
|
||||||
title = `${chanTitle} — ${title}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.title = title;
|
|
||||||
|
|
||||||
const type = chan.data("type");
|
const type = chan.data("type");
|
||||||
let placeholder = "";
|
let placeholder = "";
|
||||||
|
|
||||||
if (type === "channel" || type === "query") {
|
if (type === "channel" || type === "query") {
|
||||||
placeholder = `Write to ${chanTitle}`;
|
placeholder = `Write to ${chan.attr("aria-label")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
input
|
input
|
||||||
|
@ -217,5 +217,7 @@ function notifyMessage(targetId, channel, msg) {
|
|||||||
badge
|
badge
|
||||||
.attr("data-highlight", serverHighlight)
|
.attr("data-highlight", serverHighlight)
|
||||||
.addClass("highlight");
|
.addClass("highlight");
|
||||||
|
|
||||||
|
utils.updateTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ module.exports = {
|
|||||||
closeChan,
|
closeChan,
|
||||||
resetHeight,
|
resetHeight,
|
||||||
toggleNotificationMarkers,
|
toggleNotificationMarkers,
|
||||||
|
updateTitle,
|
||||||
togglePasswordField,
|
togglePasswordField,
|
||||||
requestIdleCallback,
|
requestIdleCallback,
|
||||||
togglePreviewMoreButtonsIfNeeded,
|
togglePreviewMoreButtonsIfNeeded,
|
||||||
@ -99,6 +100,27 @@ function toggleNotificationMarkers(newState) {
|
|||||||
viewport.toggleClass("notified", newState);
|
viewport.toggleClass("notified", newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTitle() {
|
||||||
|
let title = $(document.body).data("app-name");
|
||||||
|
const chanTitle = $("#sidebar").find(".chan.active").attr("aria-label");
|
||||||
|
|
||||||
|
if (chanTitle.length > 0) {
|
||||||
|
title = `${chanTitle} — ${title}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add highlight count to title
|
||||||
|
let alertEventCount = 0;
|
||||||
|
$(".badge.highlight").each(function() {
|
||||||
|
alertEventCount += parseInt($(this).attr("data-highlight"));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (alertEventCount > 0) {
|
||||||
|
title = `(${alertEventCount}) ${title}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
function togglePasswordField(elem) {
|
function togglePasswordField(elem) {
|
||||||
$(elem).on("click", function() {
|
$(elem).on("click", function() {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user