fix: search caching keeping old search after changing term

This commit is contained in:
Roberto Tonino 2020-11-28 17:34:22 +01:00
parent bd753865a0
commit 6789ea8be4
2 changed files with 9 additions and 4 deletions

File diff suppressed because one or more lines are too long

View file

@ -143,16 +143,17 @@ export default defineComponent({
const searchedTerm = computed(() => ctx.root.$route.query.term)
const isSearching = ref(false)
const isMainSearchCached = computed(() => Object.keys(searchResult.value).length !== 0)
const isNewQuery = computed(() => searchResult.value.QUERY !== searchedTerm.value)
console.log('onSetup', lastTab.value)
if (isMainSearchCached.value) {
if (isMainSearchCached.value && !isNewQuery.value) {
console.log('main search cached!')
onMounted(() => {
handleMainSearch(searchResult.value)
})
}
if (searchedTerm.value && !isMainSearchCached.value) {
if (searchedTerm.value && (!isMainSearchCached.value || isNewQuery.value)) {
console.log('need to perform main search')
performMainSearch(searchedTerm.value)
isSearching.value = true
@ -225,7 +226,11 @@ export default defineComponent({
isQueryEmpty,
searchResult,
performMainSearch,
performSearch
performSearch,
// Remove
isNewQuery,
searchedTerm,
isMainSearchCached
}
},
computed: {