mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 06:30:15 +08:00
8b426431a4
We want to wrap the `Ember.run.debounce` function and internally call `Ember.run` instead when running tests. This commit changes discourseDebounce to work the same way as `Ember.run.debounce`. Now that `discourseDebounce` works exactly like `Ember.run.debounce`, let's replace it and only use `DiscourseDebounce` from now on. Move debounce to discourse-common to be able to reuse it in different bundles Keep old debounce file for backwards-compatibility
44 lines
1015 B
JavaScript
44 lines
1015 B
JavaScript
import Controller from "@ember/controller";
|
|
import discourseDebounce from "discourse-common/lib/debounce";
|
|
let lastSearch;
|
|
|
|
export default Controller.extend({
|
|
searching: false,
|
|
siteTexts: null,
|
|
preferred: false,
|
|
queryParams: ["q", "overridden"],
|
|
|
|
q: null,
|
|
overridden: false,
|
|
|
|
_performSearch() {
|
|
this.store
|
|
.find("site-text", this.getProperties("q", "overridden"))
|
|
.then((results) => {
|
|
this.set("siteTexts", results);
|
|
})
|
|
.finally(() => this.set("searching", false));
|
|
},
|
|
|
|
actions: {
|
|
edit(siteText) {
|
|
this.transitionToRoute("adminSiteText.edit", siteText.get("id"));
|
|
},
|
|
|
|
toggleOverridden() {
|
|
this.toggleProperty("overridden");
|
|
this.set("searching", true);
|
|
discourseDebounce(this, this._performSearch, 400);
|
|
},
|
|
|
|
search() {
|
|
const q = this.q;
|
|
if (q !== lastSearch) {
|
|
this.set("searching", true);
|
|
discourseDebounce(this, this._performSearch, 400);
|
|
lastSearch = q;
|
|
}
|
|
},
|
|
},
|
|
});
|