FIX: Unsubscribe from the `/reviewable_counts` channel when leaving the review-index route (#17778)

Follow-up to ce9eec8606.

When the review-index route is entered, we listen to the `/reviewable_counts` (or `/reviewable_counts/<user_id>` 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.
This commit is contained in:
Osama Sayegh 2022-08-03 17:16:02 +03:00 committed by GitHub
parent 0e6f9ef406
commit 3d7829c01f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -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