mirror of
https://github.com/discourse/discourse.git
synced 2025-04-26 16:34:29 +08: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")
|
@on("didInsertElement")
|
||||||
_setupLogsNotice() {
|
_setupLogsNotice() {
|
||||||
LogsNotice.current().addObserver("hidden", () => {
|
this._boundRerenderBuffer = Ember.run.bind(this, this.rerenderBuffer);
|
||||||
this.rerenderBuffer();
|
LogsNotice.current().addObserver("hidden", this._boundRerenderBuffer);
|
||||||
});
|
|
||||||
|
|
||||||
this.$().on("click.global-notice", ".alert-logs-notice .close", () => {
|
this._boundResetCurrentProp = Ember.run.bind(
|
||||||
LogsNotice.currentProp("text", "");
|
this,
|
||||||
});
|
this._resetCurrentProp
|
||||||
|
);
|
||||||
|
$(this.element).on(
|
||||||
|
"click.global-notice",
|
||||||
|
".alert-logs-notice .close",
|
||||||
|
this._boundResetCurrentProp
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@on("willDestroyElement")
|
@on("willDestroyElement")
|
||||||
_teardownLogsNotice() {
|
_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…
x
Reference in New Issue
Block a user