Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add distraction free setting to hide channel shorts #3569

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export default defineComponent({
hideFeaturedChannels: function() {
return this.$store.getters.getHideFeaturedChannels
},
hideChannelShorts: function() {
return this.$store.getters.getHideChannelShorts
},
hideChannelPlaylists: function() {
return this.$store.getters.getHideChannelPlaylists
},
Expand Down Expand Up @@ -112,6 +115,7 @@ export default defineComponent({
'updateChannelsHidden',
'updateShowDistractionFreeTitles',
'updateHideFeaturedChannels',
'updateHideChannelShorts',
'updateHideChannelPlaylists',
'updateHideChannelCommunity'
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
:default-value="hideChannelPlaylists"
@change="updateHideChannelPlaylists"
/>
<ft-toggle-switch
:label="$t('Settings.Distraction Free Settings.Hide Channel Shorts')"
:compact="true"
:default-value="hideChannelShorts"
@change="updateHideChannelShorts"
/>
</div>
<div class="switchColumn">
<ft-toggle-switch
Expand Down
1 change: 1 addition & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ const state = {
hideActiveSubscriptions: false,
hideChannelCommunity: false,
hideChannelPlaylists: false,
hideChannelShorts: false,
hideChannelSubscriptions: false,
hideCommentLikes: false,
hideComments: false,
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/store/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ const actions = {
let urlType = 'unknown'

const channelPattern =
/^\/(?:(?:channel|user|c)\/)?(?<channelId>[^/]+)(?:\/(?<tab>join|featured|videos|live|streams|playlists|about|community|channels))?\/?$/
/^\/(?:(?:channel|user|c)\/)?(?<channelId>[^/]+)(?:\/(?<tab>join|featured|videos|shorts|live|streams|playlists|about|community|channels))?\/?$/

const hashtagPattern = /^\/hashtag\/(?<tag>[^#&/?]+)$/

Expand Down Expand Up @@ -427,6 +427,9 @@ const actions = {

let subPath = null
switch (match.groups.tab) {
case 'shorts':
subPath = 'shorts'
break
case 'live':
case 'streams':
subPath = 'live'
Expand Down
21 changes: 19 additions & 2 deletions src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export default defineComponent({
return this.$store.getters.getHideSharingActions
},

hideChannelShorts: function () {
return this.$store.getters.getHideChannelShorts
},

hideLiveStreams: function () {
return this.$store.getters.getHideLiveStreams
},
Expand All @@ -207,6 +211,11 @@ export default defineComponent({
]

// remove tabs from the array based on user settings
if (this.hideChannelShorts) {
const index = values.indexOf('shorts')
values.splice(index, 1)
}

if (this.hideLiveStreams) {
const index = values.indexOf('live')
values.splice(index, 1)
Expand Down Expand Up @@ -264,6 +273,10 @@ export default defineComponent({
this.showLiveSortBy = true
this.showPlaylistSortBy = true

if (this.hideChannelShorts && currentTab === 'shorts') {
currentTab = 'videos'
}

if (this.hideLiveStreams && currentTab === 'live') {
currentTab = 'videos'
}
Expand Down Expand Up @@ -367,6 +380,10 @@ export default defineComponent({

let currentTab = this.$route.params.currentTab ?? 'videos'

if (this.hideChannelShorts && currentTab === 'shorts') {
currentTab = 'videos'
}

if (this.hideLiveStreams && currentTab === 'live') {
currentTab = 'videos'
}
Expand Down Expand Up @@ -591,7 +608,7 @@ export default defineComponent({
this.getChannelVideosLocal()
}

if (channel.has_shorts) {
if (!this.hideChannelShorts && channel.has_shorts) {
this.getChannelShortsLocal()
}

Expand Down Expand Up @@ -883,7 +900,7 @@ export default defineComponent({
this.channelInvidiousVideos()
}

if (response.tabs.includes('shorts')) {
if (!this.hideChannelShorts && response.tabs.includes('shorts')) {
this.channelInvidiousShorts()
}

Expand Down
7 changes: 4 additions & 3 deletions src/renderer/views/Channel/Channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
{{ $t("Channel.Videos.Videos").toUpperCase() }}
</div>
<div
v-if="!hideChannelShorts"
id="shortsTab"
class="tab"
:class="(currentTab==='shorts')?'selectedTab':''"
Expand Down Expand Up @@ -203,7 +204,7 @@
@change="videoSortBy = $event"
/>
<ft-select
v-if="showShortSortBy"
v-if="!hideChannelShorts && showShortSortBy"
v-show="currentTab === 'shorts' && latestShorts.length > 0"
class="sortSelect"
:value="videoShortLiveSelectValues[0]"
Expand Down Expand Up @@ -254,14 +255,14 @@
</p>
</ft-flex-box>
<ft-element-list
v-if="currentTab === 'shorts'"
v-if="!hideChannelShorts && currentTab === 'shorts'"
id="shortPanel"
:data="latestShorts"
role="tabpanel"
aria-labelledby="shortsTab"
/>
<ft-flex-box
v-if="currentTab === 'shorts' && latestShorts.length === 0"
v-if="!hideChannelShorts && currentTab === 'shorts' && latestShorts.length === 0"
>
<p class="message">
{{ $t("Channel.Shorts.This channel does not currently have any shorts") }}
Expand Down