FIX: leaking callbacks to synchronize state (#20540)

Every time we created a topic list we would leak a state change callback

This happens on any topic list -> topic -> topic list sequence

This can cause corruption of tracking state and memory bloating given that
all information may be sent to the sync function.
This commit is contained in:
Sam 2023-03-06 15:52:24 +11:00 committed by GitHub
parent bfd4bfb824
commit c961dcc757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -27,12 +27,16 @@ export default Component.extend(UrlRefresh, LoadMore, {
@on("didInsertElement")
_monitorTrackingState() {
this.topicTrackingState.onStateChange(() => this._updateTrackingTopics());
this.stateChangeCallbackId = this.topicTrackingState.onStateChange(() =>
this._updateTrackingTopics()
);
},
@on("willDestroyElement")
_removeTrackingStateChangeMonitor() {
this.topicTrackingState.offStateChange(this.stateChangeCallbackId);
if (this.stateChangeCallbackId) {
this.topicTrackingState.offStateChange(this.stateChangeCallbackId);
}
},
_updateTrackingTopics() {