Revert "Revert "DEV: Wrap Ember.run.debounce. (#11352)"" (#11509)

* Revert "Revert "DEV: Wrap `Ember.run.debounce`. (#11352)" (#11465)"

This reverts commit aa0d4ea764959bd7ec5127f78dbec68de4dc8337.

* Correctly debounce onScroll function
This commit is contained in:
Roman Rizzi
2020-12-18 10:18:52 -03:00
committed by GitHub
parent f296ca4b4a
commit 142e0ae062
51 changed files with 526 additions and 358 deletions

View File

@ -6,7 +6,7 @@ import I18n from "I18n";
import { INPUT_DELAY } from "discourse-common/config/environment";
import { Promise } from "rsvp";
import { cookAsync } from "discourse/lib/text";
import discourseDebounce from "discourse/lib/debounce";
import discourseDebounce from "discourse-common/lib/debounce";
import { isEmpty } from "@ember/utils";
import loadScript from "discourse/lib/load-script";
import { notEmpty } from "@ember/object/computed";
@ -56,18 +56,24 @@ export default Component.extend({
},
@observes("markup")
_renderPreview: discourseDebounce(function () {
const markup = this.markup;
_renderPreview() {
discourseDebounce(
this,
function () {
const markup = this.markup;
if (markup) {
cookAsync(markup).then((result) => {
this.set("currentPreview", result);
schedule("afterRender", () =>
this.$(".preview .discourse-local-date").applyLocalDates()
);
});
}
}, INPUT_DELAY),
if (markup) {
cookAsync(markup).then((result) => {
this.set("currentPreview", result);
schedule("afterRender", () =>
this.$(".preview .discourse-local-date").applyLocalDates()
);
});
}
},
INPUT_DELAY
);
},
@computed("date", "toDate", "toTime")
isRange(date, toDate, toTime) {