mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 04:08:14 +08:00
DEV: Wrap Ember.run.debounce
. (#11352)
We want to wrap the `Ember.run.debounce` function and internally call `Ember.run` instead when running tests. This commit changes discourseDebounce to work the same way as `Ember.run.debounce`. Now that `discourseDebounce` works exactly like `Ember.run.debounce`, let's replace it and only use `DiscourseDebounce` from now on. Move debounce to discourse-common to be able to reuse it in different bundles Keep old debounce file for backwards-compatibility
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { observes, on } from "discourse-common/utils/decorators";
|
||||
import Component from "@ember/component";
|
||||
import I18n from "I18n";
|
||||
import discourseDebounce from "discourse/lib/debounce";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import { scheduleOnce } from "@ember/runloop";
|
||||
|
||||
export default Component.extend({
|
||||
@ -33,9 +33,7 @@ export default Component.extend({
|
||||
}
|
||||
},
|
||||
|
||||
@on("init")
|
||||
@observes("logs.[]")
|
||||
_updateFormattedLogs: discourseDebounce(function () {
|
||||
_updateFormattedLogsFunc: function () {
|
||||
const logs = this.logs;
|
||||
if (logs.length === 0) {
|
||||
return;
|
||||
@ -57,7 +55,13 @@ export default Component.extend({
|
||||
this.renderLogs();
|
||||
|
||||
scheduleOnce("afterRender", this, this._scrollDown);
|
||||
}, 150),
|
||||
},
|
||||
|
||||
@on("init")
|
||||
@observes("logs.[]")
|
||||
_updateFormattedLogs() {
|
||||
discourseDebounce(this, this._updateFormattedLogsFunc, 150);
|
||||
},
|
||||
|
||||
renderLogs() {
|
||||
const formattedLogs = this.formattedLogs;
|
||||
|
Reference in New Issue
Block a user