mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
parent
bfd4bfb824
commit
c961dcc757
@ -27,12 +27,16 @@ export default Component.extend(UrlRefresh, LoadMore, {
|
|||||||
|
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
_monitorTrackingState() {
|
_monitorTrackingState() {
|
||||||
this.topicTrackingState.onStateChange(() => this._updateTrackingTopics());
|
this.stateChangeCallbackId = this.topicTrackingState.onStateChange(() =>
|
||||||
|
this._updateTrackingTopics()
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@on("willDestroyElement")
|
@on("willDestroyElement")
|
||||||
_removeTrackingStateChangeMonitor() {
|
_removeTrackingStateChangeMonitor() {
|
||||||
|
if (this.stateChangeCallbackId) {
|
||||||
this.topicTrackingState.offStateChange(this.stateChangeCallbackId);
|
this.topicTrackingState.offStateChange(this.stateChangeCallbackId);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateTrackingTopics() {
|
_updateTrackingTopics() {
|
||||||
|
Loading…
Reference in New Issue
Block a user