From 3d7829c01fe351854315e21e865ae89408049b7a Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Wed, 3 Aug 2022 17:16:02 +0300 Subject: [PATCH] FIX: Unsubscribe from the `/reviewable_counts` channel when leaving the review-index route (#17778) Follow-up to https://github.com/discourse/discourse/commit/ce9eec8606e6c55ef6fa09b630464067fcea7b43. When the review-index route is entered, we listen to the `/reviewable_counts` (or `/reviewable_counts/` when the new user menu is enabled) channel so we can listen for changes to reviewables and update the UI accordingly. However, we currently don't unsubscribe when leaving the route which means each time the route is entered, we setup a new listener causing the browser to do unnecessary work and potentially state leakage. --- app/assets/javascripts/discourse/app/routes/review-index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/discourse/app/routes/review-index.js b/app/assets/javascripts/discourse/app/routes/review-index.js index 4d89d8154af..fbe993f864e 100644 --- a/app/assets/javascripts/discourse/app/routes/review-index.js +++ b/app/assets/javascripts/discourse/app/routes/review-index.js @@ -82,6 +82,10 @@ export default DiscourseRoute.extend({ deactivate() { this.messageBus.unsubscribe("/reviewable_claimed"); + const channel = this.currentUser.enable_redesigned_user_menu + ? `/reviewable_counts/${this.currentUser.id}` + : "/reviewable_counts"; + this.messageBus.unsubscribe(channel); }, @action