This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/initializers/title-notifications.js.es6
David Taylor 4e8c174ee5
FEATURE: Display notification count in title for logged in users (#7184)
This replaces the 'contextual' counters for logged in users. We will still use the old method for anon users
2019-03-18 12:59:47 +00:00

19 lines
488 B
JavaScript

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