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

Added buttons to hide hidden channels/text #6156

Merged
merged 16 commits into from
Dec 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export default defineComponent({
showDistractionFreeTitles: function () {
return this.$store.getters.getShowDistractionFreeTitles
},
showAddedChannelsHidden: function () {
return this.$store.getters.getShowAddedChannelsHidden
},
showAddedForbiddenTitles: function () {
return this.$store.getters.getShowAddedForbiddenTitles
},
channelsHidden: function () {
return JSON.parse(this.$store.getters.getChannelsHidden).map((ch) => {
// Legacy support
Expand Down Expand Up @@ -157,6 +163,12 @@ export default defineComponent({
handleChannelsExists: function () {
showToast(this.$t('Settings.Distraction Free Settings.Hide Channels Already Exists'))
},
handleAddedChannelsHidden: function () {
this.updateShowAddedChannelsHidden(!this.showAddedChannelsHidden)
},
handleAddedForbiddenTitles: function () {
this.updateShowAddedForbiddenTitles(!this.showAddedForbiddenTitles)
},
validateChannelId: function (text) {
return checkYoutubeChannelId(text)
},
Expand Down Expand Up @@ -224,6 +236,8 @@ export default defineComponent({
'updateHideSubscriptionsShorts',
'updateHideSubscriptionsLive',
'updateHideSubscriptionsCommunity',
'updateShowAddedChannelsHidden',
'updateShowAddedForbiddenTitles',
])
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,25 @@
:validate-tag-name="validateChannelId"
:find-tag-info="findChannelTagInfo"
:are-channel-tags="true"
:show-tags="showAddedChannelsHidden"
@invalid-name="handleInvalidChannel"
@error-find-tag-info="handleChannelAPIError"
@change="handleChannelsHidden"
@already-exists="handleChannelsExists"
@toggle-show-tags="handleAddedChannelsHidden"
/>
</ft-flex-box>
<ft-flex-box>
<ft-input-tags
:label="$t('Settings.Distraction Free Settings.Hide Videos and Playlists Containing Text')"
:tag-name-placeholder="$t('Settings.Distraction Free Settings.Hide Videos and Playlists Containing Text Placeholder')"
:show-action-button="true"
:show-tags="showAddedForbiddenTitles"
:tag-list="forbiddenTitles"
:min-input-length="3"
:tooltip="$t('Tooltips.Distraction Free Settings.Hide Videos and Playlists Containing Text')"
@change="handleForbiddenTitles"
@toggle-show-tags="handleAddedForbiddenTitles"
/>
</ft-flex-box>
</ft-settings-section>
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/components/ft-input-tags/ft-input-tags.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
user-select: text;
}

.checkbox-container {
display: flex;
align-items: center;
font-size: 12px;
accent-color: var(--accent-color);
}

.tag-icon {
border-radius: 50%;
vertical-align: middle;
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/components/ft-input-tags/ft-input-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export default defineComponent({
type: Boolean,
default: true
},
showTags: {
type: Boolean,
default: true
},
tagList: {
type: Array,
default: () => { return [] }
Expand All @@ -53,7 +57,7 @@ export default defineComponent({
default: (_) => ({ preferredName: '', icon: '' }),
}
},
emits: ['already-exists', 'change', 'error-find-tag-info', 'invalid-name'],
emits: ['already-exists', 'change', 'error-find-tag-info', 'invalid-name', 'toggle-show-tags'],
methods: {
updateTags: async function (text, _e) {
if (this.areChannelTags) {
Expand Down Expand Up @@ -126,6 +130,9 @@ export default defineComponent({
const newList = this.tagList.filter((tmpTag) => tmpTag.name !== tag.name)
this.$emit('change', newList)
}
}
},
toggleShowTags: function () {
this.$emit('toggle-show-tags')
},
}
})
19 changes: 18 additions & 1 deletion src/renderer/components/ft-input-tags/ft-input-tags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,24 @@
:force-action-button-icon-name="['fas', 'arrow-right']"
@click="updateTags"
/>
<div class="ft-tag-box">
<div
v-if="tagList.length >= 1"
class="checkbox-container"
>
<input
:id="label"
type="checkbox"
:checked="showTags"
@change="toggleShowTags"
>
<label :for="label">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find a way to make this id unique, as this component is shown on the page 3 times at the same time, so using the same ID for all of them will result in the wrong label getting referenced.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be unique since it's taking the label prop but it should probably be somewhat sanitized (ex: spaces removed)

{{ $t('Settings.Distraction Free Settings.Show Added Items') }}
</label>
</div>
<div
v-if="showTags"
class="ft-tag-box"
>
<ul>
<li
v-for="tag in tagList"
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ const state = {
hideFeaturedChannels: false,
channelsHidden: '[]',
forbiddenTitles: '[]',
showAddedChannelsHidden: true,
showAddedForbiddenTitles: true,
hideVideoDescription: false,
hideLiveChat: false,
hideLiveStreams: false,
Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ Settings:
Hide Subscriptions Shorts: Hide Subscriptions Shorts
Hide Subscriptions Live: Hide Subscriptions Live
Hide Subscriptions Community: Hide Subscriptions Community
Show Added Items: Show Added Items
Data Settings:
Data Settings: Data
Select Import Type: Select Import Type
Expand Down
Loading