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

Option to hide videos from certain channels #2849

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import Vue from 'vue'
import { mapActions } from 'vuex'
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'

export default Vue.extend({
name: 'PlayerSettings',
components: {
'ft-settings-section': FtSettingsSection,
'ft-toggle-switch': FtToggleSwitch
'ft-toggle-switch': FtToggleSwitch,
'ft-input-tags': FtInputTags,
'ft-flex-box': FtFlexBox
},
computed: {
hideVideoViews: function () {
Expand Down Expand Up @@ -60,6 +64,9 @@ export default Vue.extend({
},
hideChapters: function () {
return this.$store.getters.getHideChapters
},
channelsHidden: function () {
return JSON.parse(this.$store.getters.getChannelsHidden)
}
},
methods: {
Expand All @@ -70,6 +77,9 @@ export default Vue.extend({

this.updateHideRecommendedVideos(value)
},
handleChannelsHidden: function(value) {
this.updateChannelsHidden(JSON.stringify(value))
},

...mapActions([
'updateHideVideoViews',
Expand All @@ -89,7 +99,8 @@ export default Vue.extend({
'updateHideLiveStreams',
'updateHideUpcomingPremieres',
'updateHideSharingActions',
'updateHideChapters'
'updateHideChapters',
'updateChannelsHidden'
])
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@
/>
</div>
</div>
<br>
<ft-flex-box>
<ft-input-tags
:label="$t('Settings.Distraction Free Settings.Hide Channels')"
:placeholder="$t('Settings.Distraction Free Settings.Hide Channels Placeholder')"
:show-action-button="true"
:tag-list="channelsHidden"
:tooltip="$t('Tooltips.Distraction Free Settings.Hide Channels')"
@change="handleChannelsHidden"
/>
</ft-flex-box>
</ft-settings-section>
</template>

Expand Down
50 changes: 50 additions & 0 deletions src/renderer/components/ft-input-tags/ft-input-tags.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.ft-input-tags-component {
position: relative;
background-color: var(--bg-color);
padding: 20px;
border-radius: 5px;
display: block;
width: 60%;
}

.ft-tag-box ul {
overflow: auto;
display: block;
padding: 0;
margin: 0;
}

.ft-tag-box li {
list-style: none;
background-color: var(--card-bg-color);
margin: 5px;
border-radius: 5px;
display:flex;
float: left;
}

.ft-tag-box li>label {
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-all;
hyphens: auto;
}


.removeTagButton {
color: var(--primary-text-color);
opacity: 0.5;
padding: 10px;
}

.removeTagButton:hover {
cursor: pointer;
}

:deep(.ft-input-component .ft-input) {
margin-top: 10px;
}

55 changes: 55 additions & 0 deletions src/renderer/components/ft-input-tags/ft-input-tags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Vue from 'vue'
import FtInput from '../ft-input/ft-input.vue'
import FtTooltip from '../ft-tooltip/ft-tooltip.vue'

export default Vue.extend({
name: 'FtInputTags',
components: {
'ft-input': FtInput,
'ft-tooltip': FtTooltip
},
props: {
placeholder: {
type: String,
required: true
},
label: {
type: String,
required: true
},
showActionButton: {
type: Boolean,
default: true
},
tagList: {
type: Array,
default: () => { return [] }
},
tooltip: {
type: String,
default: ''
}
},
methods: {
updateTags: function (text, e) {
// text entered add tag and update tag list
if (!this.tagList.includes(text.trim())) {
const newList = this.tagList.slice(0)
newList.push(text.trim())
this.$emit('change', newList)
}
// clear input box
this.$refs.childinput.handleClearTextClick()
},
removeTag: function (tag) {
// Remove tag from list
const tagName = tag.trim()
if (this.tagList.includes(tagName)) {
const newList = this.tagList.slice(0)
const index = newList.indexOf(tagName)
newList.splice(index, 1)
this.$emit('change', newList)
}
}
}
})
39 changes: 39 additions & 0 deletions src/renderer/components/ft-input-tags/ft-input-tags.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<template>
<div
class="ft-input-tags-component"
>
<ft-input
ref="childinput"
:placeholder="placeholder"
:label="label"
:show-label="true"
:tooltip="tooltip"
:show-action-button="showActionButton"
:select-on-focus="true"
:force-action-button-icon-name="['fas', 'arrow-right']"
@click="updateTags"
/>

<div class="ft-tag-box">
<ul>
<li
v-for="tag in tagList"
:key="tag.id"
>
<label>{{ tag }}</label>
<font-awesome-icon
:icon="['fas', 'fa-times']"
class="removeTagButton"
tabindex="0"
role="button"
@click="removeTag(tag)"
@keydown.enter.prevent="removeTag(tag)"
/>
</li>
</ul>
</div>
</div>
</template>

<script src="./ft-input-tags.js" />
<style scoped src="./ft-input-tags.css" />
6 changes: 6 additions & 0 deletions src/renderer/components/ft-input/ft-input.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@
cursor: pointer;
}

.inputAction.withLabel {
/* If showLabel defined, re-centralize the input button*/
top: 34px;
}


.search ::-webkit-calendar-picker-indicator {
display: none;
}
Expand Down
35 changes: 25 additions & 10 deletions src/renderer/components/ft-input/ft-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default Vue.extend({
type: String,
required: true
},
label: {
type: String,
default: null
},
value: {
type: String,
default: ''
Expand All @@ -20,6 +24,10 @@ export default Vue.extend({
type: Boolean,
default: true
},
forceActionButtonIconName: {
type: Array,
default: null
},
showClearTextButton: {
type: Boolean,
default: false
Expand Down Expand Up @@ -54,6 +62,10 @@ export default Vue.extend({
}
},
data: function () {
let actionIcon = ['fas', 'search']
if (this.forceActionButtonIconName !== null) {
actionIcon = this.forceActionButtonIconName
}
return {
id: '',
inputData: '',
Expand All @@ -67,7 +79,7 @@ export default Vue.extend({
// As the text input box should be empty
clearTextButtonExisting: false,
clearTextButtonVisible: false,
actionButtonIconName: ['fas', 'search']
actionButtonIconName: actionIcon
}
},
computed: {
Expand Down Expand Up @@ -142,7 +154,7 @@ export default Vue.extend({
// Only need to update icon if visible
if (!this.showActionButton) { return }

if (!this.inputDataPresent) {
if (!this.inputDataPresent && this.forceActionButtonIconName === null) {
// Change back to default icon if text is blank
this.actionButtonIconName = ['fas', 'search']
return
Expand Down Expand Up @@ -170,18 +182,21 @@ export default Vue.extend({
// isYoutubeLink is already `false`
}
}

if (isYoutubeLink) {
// Go to URL (i.e. Video/Playlist/Channel
this.actionButtonIconName = ['fas', 'arrow-right']
} else {
// Search with text
this.actionButtonIconName = ['fas', 'search']
if (this.forceActionButtonIconName === null) {
if (isYoutubeLink) {
// Go to URL (i.e. Video/Playlist/Channel
this.actionButtonIconName = ['fas', 'arrow-right']
} else {
// Search with text
this.actionButtonIconName = ['fas', 'search']
}
}
})
} catch (ex) {
// On exception, consider text as invalid URL
this.actionButtonIconName = ['fas', 'search']
if (this.forceActionButtonIconName === null) {
this.actionButtonIconName = ['fas', 'search']
}
// Rethrow exception
throw ex
}
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/components/ft-input/ft-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
<label
v-if="showLabel"
:for="id"
class="selectLabel"
>
{{ placeholder }}
{{ label || placeholder }}
<ft-tooltip
v-if="tooltip !== ''"
class="selectTooltip"
Expand Down Expand Up @@ -57,7 +58,8 @@
:icon="actionButtonIconName"
class="inputAction"
:class="{
enabled: inputDataPresent
enabled: inputDataPresent,
withLabel: showLabel
}"
@click="handleClick"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export default Vue.extend({
hideLiveStreams: function() {
return this.$store.getters.getHideLiveStreams
},
channelsHidden: function() {
return JSON.parse(this.$store.getters.getChannelsHidden)
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
}
Expand All @@ -46,6 +49,11 @@ export default Vue.extend({
this.visible = visible
},

/**
* Show or Hide results in the list
*
* @return {bool} false to hide the video, true to show it
*/
showResult: function (data) {
if (!data.type) {
return false
Expand All @@ -66,8 +74,23 @@ export default Vue.extend({
// hide upcoming
return false
}
if (this.channelsHidden.includes(data.authorId) || this.channelsHidden.includes(data.author)) {
// hide videos by author
return false
}
} else if (data.type === 'channel') {
if (this.channelsHidden.includes(data.channelID) || this.channelsHidden.includes(data.name)) {
// hide channels by author
return false
}
} else if (data.type === 'playlist') {
if (this.channelsHidden.includes(data.authorId) || this.channelsHidden.includes(data.author)) {
// hide playlists by author
return false
}
}
return true
Copy link
Member

@absidue absidue Nov 24, 2022

Choose a reason for hiding this comment

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

the previous check hid the item when data is undefined, this implementation doesn't

Copy link
Contributor

@miangraham miangraham Nov 24, 2022

Choose a reason for hiding this comment

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

I believe the conflict resolutions in the rebase below will resolve this as well. See 4d618e3, L59.

Looks fixed after petaded's merge commit!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is fixed with the merge with latest development

}

}
})
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@
justify-content: flex-start

@media only screen and (max-width: 680px)
.settingsSection
> div
.settingsSection
> div
:deep(.text.bottom)
left: -85px
:deep(.switch-ctn.containsTooltip)
left: -10px
margin-right: 5px
padding: 0px 10px 0px 10px
:not(.select)
:not(.select, .selectLabel)
> :deep(.tooltip)
display: inline-block
position: absolute
Expand Down
Loading