fix: search caching keeping old search after changing term
This commit is contained in:
parent
bd753865a0
commit
6789ea8be4
File diff suppressed because one or more lines are too long
@ -143,16 +143,17 @@ export default defineComponent({
|
|||||||
const searchedTerm = computed(() => ctx.root.$route.query.term)
|
const searchedTerm = computed(() => ctx.root.$route.query.term)
|
||||||
const isSearching = ref(false)
|
const isSearching = ref(false)
|
||||||
const isMainSearchCached = computed(() => Object.keys(searchResult.value).length !== 0)
|
const isMainSearchCached = computed(() => Object.keys(searchResult.value).length !== 0)
|
||||||
|
const isNewQuery = computed(() => searchResult.value.QUERY !== searchedTerm.value)
|
||||||
console.log('onSetup', lastTab.value)
|
console.log('onSetup', lastTab.value)
|
||||||
|
|
||||||
if (isMainSearchCached.value) {
|
if (isMainSearchCached.value && !isNewQuery.value) {
|
||||||
console.log('main search cached!')
|
console.log('main search cached!')
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
handleMainSearch(searchResult.value)
|
handleMainSearch(searchResult.value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchedTerm.value && !isMainSearchCached.value) {
|
if (searchedTerm.value && (!isMainSearchCached.value || isNewQuery.value)) {
|
||||||
console.log('need to perform main search')
|
console.log('need to perform main search')
|
||||||
performMainSearch(searchedTerm.value)
|
performMainSearch(searchedTerm.value)
|
||||||
isSearching.value = true
|
isSearching.value = true
|
||||||
@ -225,7 +226,11 @@ export default defineComponent({
|
|||||||
isQueryEmpty,
|
isQueryEmpty,
|
||||||
searchResult,
|
searchResult,
|
||||||
performMainSearch,
|
performMainSearch,
|
||||||
performSearch
|
performSearch,
|
||||||
|
// Remove
|
||||||
|
isNewQuery,
|
||||||
|
searchedTerm,
|
||||||
|
isMainSearchCached
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
Loading…
Reference in New Issue
Block a user