From c53f5b6dac14f2250fca1d8947cf856ad44827f8 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Tue, 23 May 2023 02:59:24 +0200 Subject: [PATCH] Add distraction free setting to hide channel shorts (#3569) * Add distraction free setting to hide channel shorts * Add support for channel shorts URLs --- .../distraction-settings.js | 4 ++++ .../distraction-settings.vue | 6 ++++++ src/renderer/store/modules/settings.js | 1 + src/renderer/store/modules/utils.js | 5 ++++- src/renderer/views/Channel/Channel.js | 21 +++++++++++++++++-- src/renderer/views/Channel/Channel.vue | 7 ++++--- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/renderer/components/distraction-settings/distraction-settings.js b/src/renderer/components/distraction-settings/distraction-settings.js index 002749040..28437c94c 100644 --- a/src/renderer/components/distraction-settings/distraction-settings.js +++ b/src/renderer/components/distraction-settings/distraction-settings.js @@ -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 }, @@ -112,6 +115,7 @@ export default defineComponent({ 'updateChannelsHidden', 'updateShowDistractionFreeTitles', 'updateHideFeaturedChannels', + 'updateHideChannelShorts', 'updateHideChannelPlaylists', 'updateHideChannelCommunity' ]) diff --git a/src/renderer/components/distraction-settings/distraction-settings.vue b/src/renderer/components/distraction-settings/distraction-settings.vue index a152f5c71..08b7484c3 100644 --- a/src/renderer/components/distraction-settings/distraction-settings.vue +++ b/src/renderer/components/distraction-settings/distraction-settings.vue @@ -64,6 +64,12 @@ :default-value="hideChannelPlaylists" @change="updateHideChannelPlaylists" /> +
[^/]+)(?:\/(?join|featured|videos|live|streams|playlists|about|community|channels))?\/?$/ + /^\/(?:(?:channel|user|c)\/)?(?[^/]+)(?:\/(?join|featured|videos|shorts|live|streams|playlists|about|community|channels))?\/?$/ const hashtagPattern = /^\/hashtag\/(?[^#&/?]+)$/ @@ -427,6 +427,9 @@ const actions = { let subPath = null switch (match.groups.tab) { + case 'shorts': + subPath = 'shorts' + break case 'live': case 'streams': subPath = 'live' diff --git a/src/renderer/views/Channel/Channel.js b/src/renderer/views/Channel/Channel.js index 41ef0a434..27e2d9720 100644 --- a/src/renderer/views/Channel/Channel.js +++ b/src/renderer/views/Channel/Channel.js @@ -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 }, @@ -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) @@ -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' } @@ -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' } @@ -591,7 +608,7 @@ export default defineComponent({ this.getChannelVideosLocal() } - if (channel.has_shorts) { + if (!this.hideChannelShorts && channel.has_shorts) { this.getChannelShortsLocal() } @@ -883,7 +900,7 @@ export default defineComponent({ this.channelInvidiousVideos() } - if (response.tabs.includes('shorts')) { + if (!this.hideChannelShorts && response.tabs.includes('shorts')) { this.channelInvidiousShorts() } diff --git a/src/renderer/views/Channel/Channel.vue b/src/renderer/views/Channel/Channel.vue index f9b271058..23b8b3a81 100644 --- a/src/renderer/views/Channel/Channel.vue +++ b/src/renderer/views/Channel/Channel.vue @@ -99,6 +99,7 @@ {{ $t("Channel.Videos.Videos").toUpperCase() }}

{{ $t("Channel.Shorts.This channel does not currently have any shorts") }}