Add search retry functionality
This commit implements query invalidation logic that runs when the requested query is same as the last one. This allows for seamless retries of previous searches without reloading or moving around routes, improving user experience and reducing bandwidth usage. Note that this commit does not change the behavior of the search bar located in the app header.
This commit is contained in:
parent
76b44d3a39
commit
105da507d7
1 changed files with 8 additions and 2 deletions
|
@ -95,8 +95,14 @@ const Search = {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newQuery (query) {
|
newQuery (query) {
|
||||||
|
if (this.lastQuery === query) {
|
||||||
|
// Handle search retries
|
||||||
|
this.lastQuery = "" // invalidate state
|
||||||
|
this.search(query)
|
||||||
|
} else {
|
||||||
this.$router.push({ name: 'search', query: { query } })
|
this.$router.push({ name: 'search', query: { query } })
|
||||||
this.$refs.searchInput.focus()
|
this.$refs.searchInput.focus()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async search (query, searchType = null) {
|
async search (query, searchType = null) {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
|
|
Loading…
Reference in a new issue