]> Untitled Git - lemmy.git/commitdiff
Adding debounce for post name and url change
authorDessalines <tyhou13@gmx.com>
Thu, 12 Dec 2019 00:25:32 +0000 (16:25 -0800)
committerDessalines <tyhou13@gmx.com>
Thu, 12 Dec 2019 00:25:32 +0000 (16:25 -0800)
- Fixes #367

ui/src/components/post-form.tsx

index 12fb42c5eb39f72c6724678f77bf7c4275f3e54f..fd51c38f62a4ede4d7a796bfc1ba2fb23b87f97a 100644 (file)
@@ -343,7 +343,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
     i.setState(i.state);
   }
 
-  handlePostUrlChange(i: PostForm, event: any) {
+  handlePostUrlChange = debounce((i: PostForm, event: any) => {
     i.state.postForm.url = event.target.value;
     if (validURL(i.state.postForm.url)) {
       let form: SearchForm = {
@@ -367,9 +367,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
     }
 
     i.setState(i.state);
-  }
+  });
 
-  handlePostNameChange(i: PostForm, event: any) {
+  handlePostNameChange = debounce((i: PostForm, event: any) => {
     i.state.postForm.name = event.target.value;
     let form: SearchForm = {
       q: i.state.postForm.name,
@@ -387,7 +387,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
     }
 
     i.setState(i.state);
-  }
+  });
 
   handlePostBodyChange(i: PostForm, event: any) {
     i.state.postForm.body = event.target.value;