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

View File

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