From 3e855e33ae11250f79e2c621d819c08d0309e33d Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Fri, 30 Aug 2019 15:51:20 +1000 Subject: [PATCH] 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. --- .../discourse/initializers/title-notifications.js.es6 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/initializers/title-notifications.js.es6 b/app/assets/javascripts/discourse/initializers/title-notifications.js.es6 index ba24755d237..ca83d7a6397 100644 --- a/app/assets/javascripts/discourse/initializers/title-notifications.js.es6 +++ b/app/assets/javascripts/discourse/initializers/title-notifications.js.es6 @@ -6,8 +6,7 @@ export default { const user = container.lookup("current-user:main"); if (!user) return; // must be logged in - this.notifications = - user.unread_notifications + user.unread_private_messages; + this.container = container; container .lookup("app-events:main") @@ -15,6 +14,12 @@ export default { }, _updateTitle() { - Discourse.updateNotificationCount(this.notifications); + 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); } };