DEV: Use the new discourseDebounce function wrapper. (#85)

We recently merged a Discourse core's PR to replace usages of Ember's debounce and discourseDebounce with a new debounce wrapper. The new wrapper works exactly like Ember's debounce but internally calls "run" when called in test mode.

This PR replaces all usages of other debounce functions with the new wrapper and fallbacks to Ember's debounce for backward-compatibility.
This commit is contained in:
Roman Rizzi 2020-12-22 14:34:31 -03:00 committed by GitHub
parent d8f9dc8151
commit 224c8ee355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -1,7 +1,8 @@
import ModalFunctionality from "discourse/mixins/modal-functionality";
import Controller from "@ember/controller";
import { debounce } from "@ember/runloop";
import { action } from "@ember/object";
import discourseDebounce from "discourse-common/lib/debounce";
import { debounce } from "@ember/runloop";
export default Controller.extend(ModalFunctionality, {
invitees: null,
@ -14,7 +15,10 @@ export default Controller.extend(ModalFunctionality, {
@action
onFilterChanged(filter) {
debounce(this, this._fetchInvitees, filter, 250);
// TODO: Use discouseDebounce after the 2.7 release.
const debounceFunc = discourseDebounce || debounce;
debounceFunc(this, this._fetchInvitees, filter, 250);
},
@action