Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-26 11:00:28 +01:00
Use the new discourseDebounce function wrapper.
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.
Dieser Commit ist enthalten in:
Ursprung
1962388501
Commit
11ff364cbe
2 geänderte Dateien mit 24 neuen und 16 gelöschten Zeilen
|
@ -14,7 +14,6 @@
|
||||||
//= require discourse/app/lib/notification-levels
|
//= require discourse/app/lib/notification-levels
|
||||||
//= require discourse/app/lib/computed
|
//= require discourse/app/lib/computed
|
||||||
//= require discourse/app/lib/user-search
|
//= require discourse/app/lib/user-search
|
||||||
//= require discourse/app/lib/debounce
|
|
||||||
//= require discourse/app/lib/text
|
//= require discourse/app/lib/text
|
||||||
//= require discourse/app/lib/formatter
|
//= require discourse/app/lib/formatter
|
||||||
//= require discourse/app/lib/quote
|
//= require discourse/app/lib/quote
|
||||||
|
@ -85,6 +84,7 @@
|
||||||
//= require discourse-common/addon/helpers/component-for-collection
|
//= require discourse-common/addon/helpers/component-for-collection
|
||||||
//= require discourse-common/addon/helpers/component-for-row
|
//= require discourse-common/addon/helpers/component-for-row
|
||||||
//= require discourse-common/addon/lib/raw-templates
|
//= require discourse-common/addon/lib/raw-templates
|
||||||
|
//= require discourse-common/lib/debounce
|
||||||
//= require discourse/app/helpers/discourse-tag
|
//= require discourse/app/helpers/discourse-tag
|
||||||
|
|
||||||
//= require discourse/app/services/app-events
|
//= require discourse/app/services/app-events
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { CANCELLED_STATUS } from 'discourse/lib/autocomplete';
|
import { CANCELLED_STATUS } from 'discourse/lib/autocomplete';
|
||||||
|
import { debounce } from "@ember/runloop";
|
||||||
|
import discourseDebounce from "discourse-common/lib/debounce";
|
||||||
import getUrl from 'discourse-common/lib/get-url';
|
import getUrl from 'discourse-common/lib/get-url';
|
||||||
import discourseDebounce from "discourse/lib/debounce";
|
|
||||||
|
|
||||||
var cache = {},
|
var cache = {},
|
||||||
cacheTopicId,
|
cacheTopicId,
|
||||||
|
@ -40,8 +41,6 @@ function performSearch(term, topicId, includeGroups, includeMentionableGroups, i
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var debouncedSearch = discourseDebounce(performSearch, 300);
|
|
||||||
|
|
||||||
function organizeResults(r, options) {
|
function organizeResults(r, options) {
|
||||||
if (r === CANCELLED_STATUS) { return r; }
|
if (r === CANCELLED_STATUS) { return r; }
|
||||||
|
|
||||||
|
@ -119,7 +118,14 @@ export default function userSearch(options) {
|
||||||
resolve(CANCELLED_STATUS);
|
resolve(CANCELLED_STATUS);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
debouncedSearch(term,
|
// TODO: Use discouseDebounce after the 2.7 release.
|
||||||
|
let debounceFunc = discourseDebounce || debounce;
|
||||||
|
|
||||||
|
debounceFunc(
|
||||||
|
this,
|
||||||
|
function() {
|
||||||
|
performSearch(
|
||||||
|
term,
|
||||||
topicId,
|
topicId,
|
||||||
includeGroups,
|
includeGroups,
|
||||||
includeMentionableGroups,
|
includeMentionableGroups,
|
||||||
|
@ -129,7 +135,9 @@ export default function userSearch(options) {
|
||||||
function(r) {
|
function(r) {
|
||||||
clearTimeout(clearPromise);
|
clearTimeout(clearPromise);
|
||||||
resolve(organizeResults(r, options));
|
resolve(organizeResults(r, options));
|
||||||
});
|
}
|
||||||
|
)
|
||||||
});
|
},
|
||||||
|
300
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Laden …
In neuem Issue referenzieren