mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
DEV: prevents global-notice events to leak (#7732)
This commit is contained in:
parent
55325679ac
commit
dfb66334c1
@ -87,18 +87,36 @@ export default Ember.Component.extend(
|
||||
|
||||
@on("didInsertElement")
|
||||
_setupLogsNotice() {
|
||||
LogsNotice.current().addObserver("hidden", () => {
|
||||
this.rerenderBuffer();
|
||||
});
|
||||
this._boundRerenderBuffer = Ember.run.bind(this, this.rerenderBuffer);
|
||||
LogsNotice.current().addObserver("hidden", this._boundRerenderBuffer);
|
||||
|
||||
this.$().on("click.global-notice", ".alert-logs-notice .close", () => {
|
||||
LogsNotice.currentProp("text", "");
|
||||
});
|
||||
this._boundResetCurrentProp = Ember.run.bind(
|
||||
this,
|
||||
this._resetCurrentProp
|
||||
);
|
||||
$(this.element).on(
|
||||
"click.global-notice",
|
||||
".alert-logs-notice .close",
|
||||
this._boundResetCurrentProp
|
||||
);
|
||||
},
|
||||
|
||||
@on("willDestroyElement")
|
||||
_teardownLogsNotice() {
|
||||
this.$().off("click.global-notice");
|
||||
if (this._boundResetCurrentProp) {
|
||||
$(this.element).off("click.global-notice", this._boundResetCurrentProp);
|
||||
}
|
||||
|
||||
if (this._boundRerenderBuffer) {
|
||||
LogsNotice.current().removeObserver(
|
||||
"hidden",
|
||||
this._boundRerenderBuffer
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
_resetCurrentProp() {
|
||||
LogsNotice.currentProp("text", "");
|
||||
}
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user