A few more promises.

This commit is contained in:
Dessalines 2021-11-17 16:18:07 -05:00
parent 9848384f5d
commit 7cd18081f6
3 changed files with 46 additions and 25 deletions

View file

@ -782,9 +782,18 @@ export class Settings extends Component<any, SettingsState> {
this.blockPersonChoices.passedElement.element.addEventListener( this.blockPersonChoices.passedElement.element.addEventListener(
"search", "search",
debounce(async (e: any) => { debounce(async (e: any) => {
let persons = (await fetchUsers(e.detail.value)).users; try {
let choices = persons.map(pvs => personToChoice(pvs)); let persons = (await fetchUsers(e.detail.value)).users;
this.blockPersonChoices.setChoices(choices, "value", "label", true); let choices = persons.map(pvs => personToChoice(pvs));
this.blockPersonChoices.setChoices(
choices,
"value",
"label",
true
);
} catch (err) {
console.log(err);
}
}, 400), }, 400),
false false
); );
@ -807,15 +816,19 @@ export class Settings extends Component<any, SettingsState> {
this.blockCommunityChoices.passedElement.element.addEventListener( this.blockCommunityChoices.passedElement.element.addEventListener(
"search", "search",
debounce(async (e: any) => { debounce(async (e: any) => {
let communities = (await fetchCommunities(e.detail.value)) try {
.communities; let communities = (await fetchCommunities(e.detail.value))
let choices = communities.map(cv => communityToChoice(cv)); .communities;
this.blockCommunityChoices.setChoices( let choices = communities.map(cv => communityToChoice(cv));
choices, this.blockCommunityChoices.setChoices(
"value", choices,
"label", "value",
true "label",
); true
);
} catch (err) {
console.log(err);
}
}, 400), }, 400),
false false
); );

View file

@ -586,14 +586,18 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
this.choices.passedElement.element.addEventListener( this.choices.passedElement.element.addEventListener(
"search", "search",
debounce(async (e: any) => { debounce(async (e: any) => {
let communities = (await fetchCommunities(e.detail.value)) try {
.communities; let communities = (await fetchCommunities(e.detail.value))
this.choices.setChoices( .communities;
communities.map(cv => communityToChoice(cv)), this.choices.setChoices(
"value", communities.map(cv => communityToChoice(cv)),
"label", "value",
true "label",
); true
);
} catch (err) {
console.log(err);
}
}, 400), }, 400),
false false
); );

View file

@ -778,11 +778,15 @@ export class Search extends Component<any, SearchState> {
this.communityChoices.passedElement.element.addEventListener( this.communityChoices.passedElement.element.addEventListener(
"search", "search",
debounce(async (e: any) => { debounce(async (e: any) => {
let communities = (await fetchCommunities(e.detail.value)) try {
.communities; let communities = (await fetchCommunities(e.detail.value))
let choices = communities.map(cv => communityToChoice(cv)); .communities;
choices.unshift({ value: "0", label: i18n.t("all") }); let choices = communities.map(cv => communityToChoice(cv));
this.communityChoices.setChoices(choices, "value", "label", true); choices.unshift({ value: "0", label: i18n.t("all") });
this.communityChoices.setChoices(choices, "value", "label", true);
} catch (err) {
console.log(err);
}
}, 400), }, 400),
false false
); );