From 105da507d77733b8d774dd4eb09a01d6103865f4 Mon Sep 17 00:00:00 2001 From: itepechi Date: Thu, 9 May 2024 14:15:45 +0900 Subject: [PATCH] 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. --- src/components/search/search.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/search/search.js b/src/components/search/search.js index 4029245b..333f9294 100644 --- a/src/components/search/search.js +++ b/src/components/search/search.js @@ -95,8 +95,14 @@ const Search = { }, methods: { newQuery (query) { - this.$router.push({ name: 'search', query: { query } }) - this.$refs.searchInput.focus() + if (this.lastQuery === query) { + // Handle search retries + this.lastQuery = "" // invalidate state + this.search(query) + } else { + this.$router.push({ name: 'search', query: { query } }) + this.$refs.searchInput.focus() + } }, async search (query, searchType = null) { if (!query) {