Skip to content

Commit

Permalink
! Fix search tab showing "0 results" before search done
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Oct 16, 2024
1 parent cdc64d0 commit 03f887e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
Expand Down Expand Up @@ -296,6 +297,14 @@ export default defineComponent({

return values
},

isCurrentTabLoading() {
if (this.currentTab === 'search') {
return this.isSearchTabLoading
}

return this.isElementListLoading
},
},
watch: {
$route() {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)')
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/views/Channel/Channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
/>
</div>
<ft-loader
v-if="isElementListLoading"
v-if="isCurrentTabLoading"
/>
<div
v-if="currentTab !== 'about' && !isElementListLoading"
Expand Down Expand Up @@ -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") }}
Expand Down

0 comments on commit 03f887e

Please sign in to comment.