FIX: Hide notification count on document title in Do Not Disturb (#11646)
This commit is contained in:
parent
d15159dff7
commit
aa909f58a9
|
@ -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}`;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue