Merge pull request #64 from romanrizzi/debounce_wrapper
Use the new discourseDebounce function wrapper.
Dieser Commit ist enthalten in:
Commit
7389afe239
2 geänderte Dateien mit 21 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
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CANCELLED_STATUS } from 'discourse/lib/autocomplete';
|
import { CANCELLED_STATUS } from 'discourse/lib/autocomplete';
|
||||||
|
import { debounce } from "@ember/runloop";
|
||||||
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 +40,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 +117,12 @@ export default function userSearch(options) {
|
||||||
resolve(CANCELLED_STATUS);
|
resolve(CANCELLED_STATUS);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
debouncedSearch(term,
|
// TODO: Use discouseDebounce after it is available on stable.
|
||||||
|
debounce(
|
||||||
|
this,
|
||||||
|
function() {
|
||||||
|
performSearch(
|
||||||
|
term,
|
||||||
topicId,
|
topicId,
|
||||||
includeGroups,
|
includeGroups,
|
||||||
includeMentionableGroups,
|
includeMentionableGroups,
|
||||||
|
@ -129,7 +132,10 @@ 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