Hide the channel sort by dropdown when the tab isn't sortable (#3323)

* Hide the channel sort by dropdown when the tab isn't sortable

* Hide playlists sort by if there is only one playlist
This commit is contained in:
absidue 2023-03-22 13:12:42 +01:00 committed by GitHub
parent 4433a183c9
commit 5dd8fb0b59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -71,6 +71,9 @@ export default defineComponent({
videoSortBy: 'newest',
liveSortBy: 'newest',
playlistSortBy: 'newest',
showVideoSortBy: true,
showLiveSortBy: true,
showPlaylistSortBy: true,
lastSearchQuery: '',
relatedChannels: [],
latestVideos: [],
@ -261,6 +264,9 @@ export default defineComponent({
this.searchContinuationData = null
this.communityContinuationData = null
this.showSearchBar = true
this.showVideoSortBy = true
this.showLiveSortBy = true
this.showPlaylistSortBy = true
if (this.hideLiveStreams && currentTab === 'live') {
currentTab = 'videos'
@ -629,7 +635,9 @@ export default defineComponent({
const channel = this.channelInstance
let videosTab = await channel.getVideos()
if (this.videoSortBy !== 'newest') {
this.showVideoSortBy = videosTab.filters.length > 1
if (this.showVideoSortBy && this.videoSortBy !== 'newest') {
const index = this.videoShortLiveSelectValues.indexOf(this.videoSortBy)
videosTab = await videosTab.applyFilter(videosTab.filters[index])
}
@ -685,7 +693,9 @@ export default defineComponent({
const channel = this.channelInstance
let liveTab = await channel.getLiveStreams()
if (this.liveSortBy !== 'newest') {
this.showLiveSortBy = liveTab.filters.length > 1
if (this.showLiveSortBy && this.liveSortBy !== 'newest') {
const index = this.videoShortLiveSelectValues.indexOf(this.liveSortBy)
liveTab = await liveTab.applyFilter(liveTab.filters[index])
}
@ -919,7 +929,11 @@ export default defineComponent({
playlistsTab = await playlistsTab.applyContentTypeFilter(createdPlaylistsFilter)
}
if (this.playlistSortBy !== 'newest' && playlistsTab.sort_filters.length > 0) {
// YouTube seems to allow the playlists tab to be sorted even if it only has one playlist
// as it doesn't make sense to sort a list with a single playlist in it, we'll hide the sort by element if there is a single playlist
this.showPlaylistSortBy = playlistsTab.sort_filters.length > 1 && playlistsTab.playlists.length > 1
if (this.showPlaylistSortBy && this.playlistSortBy !== 'newest') {
const index = this.playlistSelectValues.indexOf(this.playlistSortBy)
playlistsTab = await playlistsTab.applySort(playlistsTab.sort_filters[index])
}

View File

@ -277,6 +277,7 @@
</ft-flex-box>
</div>
<ft-select
v-if="showVideoSortBy"
v-show="currentTab === 'videos' && latestVideos.length > 0"
class="sortSelect"
:value="videoShortLiveSelectValues[0]"
@ -286,7 +287,7 @@
@change="videoSortBy = $event"
/>
<ft-select
v-if="!hideLiveStreams"
v-if="!hideLiveStreams && showLiveSortBy"
v-show="currentTab === 'live' && latestLive.length > 0"
class="sortSelect"
:value="videoShortLiveSelectValues[0]"
@ -296,6 +297,7 @@
@change="liveSortBy = $event"
/>
<ft-select
v-if="showPlaylistSortBy"
v-show="currentTab === 'playlists' && latestPlaylists.length > 0"
class="sortSelect"
:value="playlistSelectValues[0]"