FIX: Hide notification count on document title in Do Not Disturb (#11646)

This commit is contained in:
Mark VanLandingham 2021-01-06 16:15:04 -06:00 committed by GitHub
parent d15159dff7
commit aa909f58a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -82,6 +82,11 @@ export default Service.extend({
let displayCount = this._displayCount();
let dynamicFavicon = this.currentUser && this.currentUser.dynamic_favicon;
if (this.currentUser && this.currentUser.isInDoNotDisturb()) {
document.title = title;
return;
}
if (displayCount > 0 && !dynamicFavicon) {
title = `(${displayCount}) ${title}`;
}

View File

@ -42,6 +42,22 @@ discourseModule("Unit | Service | document-title", function (hooks) {
assert.equal(document.title, "test notifications");
});
test("it doesn't display notification counts for users in do not disturb", function (assert) {
this.documentTitle.currentUser = currentUser();
const date = new Date();
date.setHours(date.getHours() + 1);
this.documentTitle.currentUser.do_not_disturb_until = date.toUTCString();
this.documentTitle.currentUser.dynamic_favicon = false;
this.documentTitle.setTitle("test notifications");
this.documentTitle.updateNotificationCount(5);
assert.equal(document.title, "test notifications");
this.documentTitle.setFocus(false);
this.documentTitle.updateNotificationCount(6);
assert.equal(document.title, "test notifications");
});
test("it doesn't increment background context counts when focused", function (assert) {
this.documentTitle.setTitle("background context");
this.documentTitle.setFocus(true);