Adding a loading indicator for post community searching. Fixes #692 (#794)

This commit is contained in:
Dessalines 2022-09-22 14:13:22 -04:00 committed by GitHub
parent 67c83ece5b
commit 93bee57c4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 39 deletions

View file

@ -80,6 +80,7 @@ interface PostFormState {
crossPosts: Option<PostView[]>;
loading: boolean;
imageLoading: boolean;
communitySearchLoading: boolean;
previewMode: boolean;
}
@ -99,6 +100,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
}),
loading: false,
imageLoading: false,
communitySearchLoading: false,
previewMode: false,
suggestedTitle: None,
suggestedPosts: None,
@ -366,7 +368,11 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
className="col-sm-2 col-form-label"
htmlFor="post-community"
>
{i18n.t("community")}
{this.state.communitySearchLoading ? (
<Spinner />
) : (
i18n.t("community")
)}
</label>
<div className="col-sm-10">
<select
@ -668,6 +674,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
},
false
);
this.choices.passedElement.element.addEventListener("search", () => {
this.setState({ communitySearchLoading: true });
});
this.choices.passedElement.element.addEventListener(
"search",
debounce(async (e: any) => {
@ -680,6 +689,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
"label",
true
);
this.setState({ communitySearchLoading: false });
} catch (err) {
console.log(err);
}