Files
discourse/app/assets/javascripts/discourse/initializers/title-notifications.js.es6
Sam Saffron 3e855e33ae FIX: notifications not updating correctly from background tab
We refactored some code to avoid app event leak in tests at c462c2f2

Unfortunately this broke all background notifications in title and they
were broken for the past multiple months.
2019-08-30 15:51:20 +10:00

26 lines
621 B
JavaScript

export default {
name: "title-notifications",
after: "message-bus",
initialize(container) {
const user = container.lookup("current-user:main");
if (!user) return; // must be logged in
this.container = container;
container
.lookup("app-events:main")
.on("notifications:changed", this, "_updateTitle");
},
_updateTitle() {
const user = this.container.lookup("current-user:main");
if (!user) return; // must be logged in
const notifications =
user.unread_notifications + user.unread_private_messages;
Discourse.updateNotificationCount(notifications);
}
};