FIX: display conextual count on favicon if selected

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.

diff --git a/app/assets/javascripts/discourse.js.es6 b/app/assets/javascripts/discourse.js.es6
index ef6bbe5..b1784a9 100644
--- a/app/assets/javascripts/discourse.js.es6
+++ b/app/assets/javascripts/discourse.js.es6
@@ -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);
     }
diff --git a/app/assets/javascripts/discourse/templates/preferences/interface.hbs b/app/assets/javascripts/discourse/templates/preferences/interface.hbs
index 61f1303..e1192d1 100644
--- a/app/assets/javascripts/discourse/templates/preferences/interface.hbs
+++ b/app/assets/javascripts/discourse/templates/preferences/interface.hbs
@@ -49,7 +49,6 @@
 
   {{preference-checkbox labelKey="user.external_links_in_new_tab" checked=model.user_option.external_links_in_new_tab}}
   {{preference-checkbox labelKey="user.enable_quoting" checked=model.user_option.enable_quoting}}
-  {{preference-checkbox labelKey="user.dynamic_favicon" checked=model.user_option.dynamic_favicon}}
   {{#if siteSettings.automatically_unpin_topics}}
     {{preference-checkbox labelKey="user.automatically_unpin_topics" checked=model.user_option.automatically_unpin_topics}}
   {{/if}}
@@ -57,6 +56,7 @@
   {{#if isiPad}}
     {{preference-checkbox labelKey="user.enable_physical_keyboard" checked=disableSafariHacks}}
   {{/if}}
+  {{preference-checkbox labelKey="user.dynamic_favicon" checked=model.user_option.dynamic_favicon}}
   <div class='controls controls-dropdown'>
     <label for="user-email-level">{{i18n 'user.title_count_mode.title'}}</label>
     {{combo-box valueAttribute="value"
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index f6e3fbd..034482c 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -772,7 +772,7 @@ en:
       dismiss_notifications: "Dismiss All"
       dismiss_notifications_tooltip: "Mark all unread notifications as read"
       first_notification: "Your first notification! Select it to begin."
-      dynamic_favicon: "Show new / updated topic count on browser icon"
+      dynamic_favicon: "Show counts on browser icon"
       theme_default_on_all_devices: "Make this the default theme on all my devices"
       text_size_default_on_all_devices: "Make this the default text size on all my devices"
       allow_private_messages: "Allow other users to send me personal messages"
diff --git a/test/javascripts/fixtures/session-fixtures.js.es6 b/test/javascripts/fixtures/session-fixtures.js.es6
index b04d5b2..c4184c1 100644
--- a/test/javascripts/fixtures/session-fixtures.js.es6
+++ b/test/javascripts/fixtures/session-fixtures.js.es6
@@ -26,7 +26,8 @@ export default {
       custom_fields: {},
       muted_category_ids: [],
       dismissed_banner_key: null,
-      akismet_review_count: 0
+      akismet_review_count: 0,
+      title_count_mode: "notifications"
     }
   }
 };

GitHub sha: 9bd3afda

FYI @davidtaylorhq some minor changes were needed, nothing drastic.

2 Likes