fix: Fire query only if search term is available (#1413)

This commit is contained in:
Pranav Raj S 2020-11-16 13:08:36 +05:30 committed by GitHub
parent ef99fd3311
commit faaed17418
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,18 +89,19 @@ export default {
onInputSearch(event) {
const newQuery = event.target.value;
const refetchAllContacts = !!this.searchQuery && newQuery === '';
if (refetchAllContacts) {
this.$store.dispatch('contacts/get', { page: 1 });
}
this.searchQuery = event.target.value;
this.searchQuery = newQuery;
},
onSearchSubmit() {
this.selectedContactId = '';
if (this.searchQuery) {
this.$store.dispatch('contacts/search', {
search: this.searchQuery,
page: 1,
});
}
},
onPageChange(page) {
this.selectedContactId = '';