diff --git a/assets/javascripts/wizard-custom.js b/assets/javascripts/wizard-custom.js index c9a8c915..5d18328f 100644 --- a/assets/javascripts/wizard-custom.js +++ b/assets/javascripts/wizard-custom.js @@ -14,7 +14,6 @@ //= require discourse/app/lib/notification-levels //= require discourse/app/lib/computed //= require discourse/app/lib/user-search -//= require discourse/app/lib/debounce //= require discourse/app/lib/text //= require discourse/app/lib/formatter //= require discourse/app/lib/quote diff --git a/assets/javascripts/wizard/lib/user-search.js.es6 b/assets/javascripts/wizard/lib/user-search.js.es6 index 617825d1..5a86d8d8 100644 --- a/assets/javascripts/wizard/lib/user-search.js.es6 +++ b/assets/javascripts/wizard/lib/user-search.js.es6 @@ -1,6 +1,6 @@ import { CANCELLED_STATUS } from 'discourse/lib/autocomplete'; +import { debounce } from "@ember/runloop"; import getUrl from 'discourse-common/lib/get-url'; -import discourseDebounce from "discourse/lib/debounce"; var cache = {}, cacheTopicId, @@ -40,8 +40,6 @@ function performSearch(term, topicId, includeGroups, includeMentionableGroups, i }); } -var debouncedSearch = discourseDebounce(performSearch, 300); - function organizeResults(r, options) { if (r === CANCELLED_STATUS) { return r; } @@ -119,17 +117,25 @@ export default function userSearch(options) { resolve(CANCELLED_STATUS); }, 5000); - debouncedSearch(term, - topicId, - includeGroups, - includeMentionableGroups, - includeMessageableGroups, - allowedUsers, - group, - function(r) { - clearTimeout(clearPromise); - resolve(organizeResults(r, options)); - }); - + // TODO: Use discouseDebounce after it is available on stable. + debounce( + this, + function() { + performSearch( + term, + topicId, + includeGroups, + includeMentionableGroups, + includeMessageableGroups, + allowedUsers, + group, + function(r) { + clearTimeout(clearPromise); + resolve(organizeResults(r, options)); + } + ) + }, + 300 + ) }); }