! Fix search tab showing "0 results" before search done

This commit is contained in:
PikachuEXE 2024-10-16 09:44:51 +08:00
parent cdc64d078d
commit 03f887ecf1
No known key found for this signature in database
2 changed files with 14 additions and 5 deletions

View File

@ -64,6 +64,7 @@ export default defineComponent({
skipRouteChangeWatcherOnce: false,
isLoading: true,
isElementListLoading: false,
isSearchTabLoading: false,
currentTab: 'videos',
id: '',
/** @type {import('youtubei.js').YT.Channel|null} */
@ -296,6 +297,14 @@ export default defineComponent({
return values
},
isCurrentTabLoading() {
if (this.currentTab === 'search') {
return this.isSearchTabLoading
}
return this.isElementListLoading
},
},
watch: {
$route() {
@ -1898,7 +1907,7 @@ export default defineComponent({
newSearch: function (query) {
this.lastSearchQuery = query
this.searchContinuationData = null
this.isElementListLoading = true
this.isSearchTabLoading = true
this.searchPage = 1
this.searchResults = []
this.changeTab('search')
@ -1953,7 +1962,7 @@ export default defineComponent({
}
this.searchContinuationData = result.has_continuation ? result : null
this.isElementListLoading = false
this.isSearchTabLoading = false
} catch (err) {
console.error(err)
const errorMessage = this.$t('Local API Error (Click to copy)')
@ -1989,7 +1998,7 @@ export default defineComponent({
} else {
this.searchResults = this.searchResults.concat(response)
}
this.isElementListLoading = false
this.isSearchTabLoading = false
this.searchPage++
}).catch((err) => {
console.error(err)

View File

@ -81,7 +81,7 @@
/>
</div>
<ft-loader
v-if="isElementListLoading"
v-if="isCurrentTabLoading"
/>
<div
v-if="currentTab !== 'about' && !isElementListLoading"
@ -201,7 +201,7 @@
:use-channels-hidden-preference="false"
/>
<ft-flex-box
v-if="currentTab === 'search' && searchResults.length === 0"
v-if="currentTab === 'search' && !isSearchTabLoading && searchResults.length === 0"
>
<p class="message">
{{ $t("Channel.Your search results have returned 0 results") }}