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

View file

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

View file

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