Skip to content

Commit

Permalink
FIX: display conextual count on favicon if selected
Browse files Browse the repository at this point in the history
This also corrects the test suite and moves the two notification counts
so they are closer together.
  • Loading branch information
SamSaffron committed Apr 12, 2019
1 parent b38cf41 commit 9bd3afd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
19 changes: 10 additions & 9 deletions app/assets/javascripts/discourse.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,22 @@ 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}`;
}

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")) {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@

{{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}}
{{preference-checkbox labelKey="user.hide_profile_and_presence" checked=model.user_option.hide_profile_and_presence}}
{{#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"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion test/javascripts/fixtures/session-fixtures.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
};

1 comment on commit 9bd3afd

@SamSaffron
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.