DEV: correctly teardown page changed event (#34383)

We were not unsubscribing from this event, causing us to add more and
more listeners, after few pages visits you would end up with as many
subscriptions and as many ajax calls, eventually causing 429s.

A further improvement of this code could be to cache the events list,
there not much value in refetching each time given the query doesnt
change for each page.
This commit is contained in:
Joffrey JAFFEUX
2025-08-18 13:34:54 +02:00
committed by GitHub
parent a745949aeb
commit fc3ba98d03
@@ -47,6 +47,11 @@ export default class UpcomingEventsList extends Component {
this.appEvents.on("page:changed", this, this.updateEventsList);
}
willDestroy() {
super.willDestroy(...arguments);
this.appEvents.off("page:changed", this, this.updateEventsList);
}
get categoryId() {
return this.router.currentRoute.attributes?.category?.id;
}