mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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.
26 lines
621 B
JavaScript
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);
|
|
}
|
|
};
|