diff --git a/src/renderer/components/distraction-settings/distraction-settings.js b/src/renderer/components/distraction-settings/distraction-settings.js
index 7f5e3741fc962..0c7ce3efa06cd 100644
--- a/src/renderer/components/distraction-settings/distraction-settings.js
+++ b/src/renderer/components/distraction-settings/distraction-settings.js
@@ -4,6 +4,8 @@ import FtSettingsSection from '../ft-settings-section/ft-settings-section.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import FtInputTags from '../../components/ft-input-tags/ft-input-tags.vue'
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
+import { showToast } from '../../helpers/utils'
+import { checkYoutubeId, findChannelTagInfo } from '../../helpers/channels'
export default defineComponent({
name: 'PlayerSettings',
@@ -13,7 +15,18 @@ export default defineComponent({
'ft-input-tags': FtInputTags,
'ft-flex-box': FtFlexBox,
},
+ data: function () {
+ return {
+ channelHiderDisabled: false,
+ }
+ },
computed: {
+ backendOptions: function () {
+ return {
+ preference: this.$store.getters.getBackendPreference,
+ fallback: this.$store.getters.getBackendFallback
+ }
+ },
hideVideoViews: function () {
return this.$store.getters.getHideVideoViews
},
@@ -92,7 +105,7 @@ export default defineComponent({
hideSubscriptionsLive: function () {
return this.$store.getters.getHideSubscriptionsLive
},
- hideSubscriptionsCommunity: function() {
+ hideSubscriptionsCommunity: function () {
return this.$store.getters.getHideSubscriptionsCommunity
},
showDistractionFreeTitles: function () {
@@ -105,7 +118,13 @@ export default defineComponent({
return this.$store.getters.getBlurThumbnails
},
channelsHidden: function () {
- return JSON.parse(this.$store.getters.getChannelsHidden)
+ return JSON.parse(this.$store.getters.getChannelsHidden).map((ch) => {
+ // Legacy support
+ if (typeof ch === 'string') {
+ return { name: ch, preferredName: '', icon: '' }
+ }
+ return ch
+ })
},
hideSubscriptionsLiveTooltip: function () {
return this.$t('Tooltips.Distraction Free Settings.Hide Subscriptions Live', {
@@ -115,6 +134,9 @@ export default defineComponent({
})
}
},
+ mounted: function () {
+ this.verifyChannelsHidden()
+ },
methods: {
handleHideRecommendedVideos: function (value) {
if (value) {
@@ -123,9 +145,51 @@ export default defineComponent({
this.updateHideRecommendedVideos(value)
},
+ handleInvalidChannel: function () {
+ showToast(this.$t('Settings.Distraction Free Settings.Hide Channels Invalid'))
+ },
+ handleChannelAPIError: function () {
+ showToast(this.$t('Settings.Distraction Free Settings.Hide Channels API Error'))
+ },
handleChannelsHidden: function (value) {
this.updateChannelsHidden(JSON.stringify(value))
},
+ handleChannelsExists: function () {
+ showToast(this.$t('Settings.Distraction Free Settings.Hide Channels Already Exists'))
+ },
+ validateChannelId: function (text) {
+ return checkYoutubeId(text)
+ },
+ findChannelTagInfo: async function (text) {
+ return await findChannelTagInfo(text, this.backendOptions)
+ },
+ verifyChannelsHidden: async function () {
+ const channelsHiddenCpy = [...this.channelsHidden]
+
+ for (let i = 0; i < channelsHiddenCpy.length; i++) {
+ const tag = this.channelsHidden[i]
+
+ // if channel has been processed and confirmed as non existent, skip
+ if (tag.invalid) continue
+
+ // process if no preferred name and is possibly a YouTube ID
+ if (tag.preferredName === '' && checkYoutubeId(tag.name)) {
+ this.channelHiderDisabled = true
+
+ const { preferredName, icon, iconHref, invalidId } = await this.findChannelTagInfo(tag.name)
+ if (invalidId) {
+ channelsHiddenCpy[i] = { name: tag.name, invalid: invalidId }
+ } else {
+ channelsHiddenCpy[i] = { name: tag.name, preferredName, icon, iconHref }
+ }
+
+ // update on every tag in case it closes
+ this.handleChannelsHidden(channelsHiddenCpy)
+ }
+ }
+
+ this.channelHiderDisabled = false
+ },
...mapActions([
'updateHideVideoViews',
diff --git a/src/renderer/components/distraction-settings/distraction-settings.vue b/src/renderer/components/distraction-settings/distraction-settings.vue
index 5b6f06db4a4a1..b30e8fd68bef7 100644
--- a/src/renderer/components/distraction-settings/distraction-settings.vue
+++ b/src/renderer/components/distraction-settings/distraction-settings.vue
@@ -237,12 +237,19 @@