FIX: display conextual count on favicon if selected

This also corrects the test suite and moves the two notification counts
so they are closer together.
This commit is contained in:
Sam Saffron
2019-04-12 10:04:11 +10:00
parent b38cf41c65
commit 9bd3afda5d
4 changed files with 14 additions and 12 deletions

View File

@ -51,12 +51,7 @@ const Discourse = Ember.Application.extend({
$("title").text(title);
}
var displayCount =
Discourse.User.current() &&
Discourse.User.currentProp("title_count_mode") === "notifications"
? this.get("notificationCount")
: this.get("contextCount");
var displayCount = this.get("displayCount");
if (displayCount > 0 && !Discourse.User.currentProp("dynamic_favicon")) {
title = `(${displayCount}) ${title}`;
}
@ -64,6 +59,14 @@ const Discourse = Ember.Application.extend({
document.title = title;
},
@computed("contextCount", "notificationCount")
displayCount() {
return Discourse.User.current() &&
Discourse.User.currentProp("title_count_mode") === "notifications"
? this.get("notificationCount")
: this.get("contextCount");
},
@observes("contextCount", "notificationCount")
faviconChanged() {
if (Discourse.User.currentProp("dynamic_favicon")) {
@ -76,9 +79,7 @@ const Discourse = Ember.Application.extend({
url = Discourse.getURL("/favicon/proxied?" + encodeURIComponent(url));
}
var displayCount = Discourse.User.current()
? this.get("notificationCount")
: this.get("contextCount");
var displayCount = this.get("displayCount");
new window.Favcount(url).set(displayCount);
}