Add setting: Distraction Free Settings → Hide Upcoming Premieres (#2853)

This commit is contained in:
M. Ian Graham 2022-11-24 21:31:53 +09:00 committed by GitHub
parent 50306689b7
commit 207d72a9c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 69 additions and 3 deletions

View File

@ -49,6 +49,9 @@ export default Vue.extend({
hideLiveStreams: function() {
return this.$store.getters.getHideLiveStreams
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
},
hideSharingActions: function () {
return this.$store.getters.getHideSharingActions
},
@ -84,6 +87,7 @@ export default Vue.extend({
'updateHideVideoDescription',
'updateHideComments',
'updateHideLiveStreams',
'updateHideUpcomingPremieres',
'updateHideSharingActions',
'updateHideChapters'
])

View File

@ -90,6 +90,12 @@
:default-value="hideLiveStreams"
@change="updateHideLiveStreams"
/>
<ft-toggle-switch
:label="$t('Settings.Distraction Free Settings.Hide Upcoming Premieres')"
:compact="true"
:default-value="hideUpcomingPremieres"
@change="updateHideUpcomingPremieres"
/>
<ft-toggle-switch
:label="$t('Settings.Distraction Free Settings.Hide Comments')"
:compact="true"

View File

@ -36,11 +36,38 @@ export default Vue.extend({
computed: {
hideLiveStreams: function() {
return this.$store.getters.getHideLiveStreams
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
}
},
methods: {
onVisibilityChanged: function (visible) {
this.visible = visible
},
showResult: function (data) {
if (!data.type) {
return false
}
if (data.type === 'video') {
if (this.hideLiveStreams && (data.liveNow || data.lengthSeconds == null)) {
// hide livestreams
return false
}
if (this.hideUpcomingPremieres &&
// Observed for premieres in Local API Channels.
(data.durationText === 'PREMIERE' ||
// viewCount is our only method of detecting premieres in RSS
// data without sending an additional request.
// If we ever get a better flag, use it here instead.
(data.isRSS && data.viewCount === '0'))) {
// hide upcoming
return false
}
}
return true
}
}
})

View File

@ -1,6 +1,6 @@
<template>
<div
v-if="data.type !== undefined && (data.type === 'video' ? ((!data.liveNow && (data.lengthSeconds != null)) || (!hideLiveStreams)) : true)"
v-if="showResult(data)"
v-observe-visibility="firstScreen ? false : {
callback: onVisibilityChanged,
once: true,

View File

@ -223,6 +223,10 @@ export default Vue.extend({
return this.$store.getters.getHideLiveStreams
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
},
hideVideoViews: function () {
return this.$store.getters.getHideVideoViews
},

View File

@ -205,6 +205,7 @@ const state = {
hideSharingActions: false,
hideTrendingVideos: false,
hideUnsubscribeButton: false,
hideUpcomingPremieres: false,
hideVideoLikesAndDislikes: false,
hideVideoViews: false,
hideWatchedSubs: false,

View File

@ -42,6 +42,11 @@ export default Vue.extend({
hideLiveStreams: function() {
return this.$store.getters.getHideLiveStreams
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
},
showFamilyFriendlyOnly: function() {
return this.$store.getters.getShowFamilyFriendlyOnly
}
@ -149,7 +154,7 @@ export default Vue.extend({
const publishDate = video.uploadedAt
let videoDuration = video.duration
const videoId = video.id
if (videoDuration !== null && videoDuration !== '' && videoDuration !== 'LIVE' && videoDuration !== 'UPCOMING') {
if (videoDuration !== null && videoDuration !== '' && videoDuration !== 'LIVE' && videoDuration !== 'UPCOMING' && videoDuration !== 'PREMIERE') {
videoDuration = calculateLengthInSeconds(video.duration)
}
dataToShow.push(
@ -169,7 +174,7 @@ export default Vue.extend({
liveNow: video.isLive || videoDuration === 'LIVE',
paid: false,
premium: false,
isUpcoming: videoDuration === 'UPCOMING',
isUpcoming: videoDuration === 'UPCOMING' || videoDuration === 'PREMIERE',
timeText: videoDuration
}
)

View File

@ -88,6 +88,11 @@ export default Vue.extend({
hideLiveStreams: function() {
return this.$store.getters.getHideLiveStreams
},
hideUpcomingPremieres: function () {
return this.$store.getters.getHideUpcomingPremieres
},
fetchSubscriptionsAutomatically: function() {
return this.$store.getters.getFetchSubscriptionsAutomatically
}
@ -195,6 +200,18 @@ export default Vue.extend({
return (!item.liveNow && !item.isUpcoming)
})
}
if (this.hideUpcomingPremieres) {
videoList = videoList.filter(item => {
if (item.isRSS) {
// viewCount is our only method of detecting premieres in RSS
// data without sending an additional request.
// If we ever get a better flag, use it here instead.
return item.viewCount !== '0'
}
// Observed for premieres in Local API Subscriptions.
return item.durationText !== 'PREMIERE'
})
}
const profileSubscriptions = {
activeProfile: this.activeProfile._id,
videoList: videoList,

View File

@ -322,6 +322,7 @@ Settings:
Hide Video Description: Hide Video Description
Hide Comments: Hide Comments
Hide Live Streams: Hide Live Streams
Hide Upcoming Premieres: Hide Upcoming Premieres
Hide Sharing Actions: Hide Sharing Actions
Hide Chapters: Hide Chapters
Data Settings:

View File

@ -391,6 +391,7 @@ Settings:
Hide Comments: Hide comments
Hide Video Description: Hide video description
Hide Live Streams: Hide live streams
Hide Upcoming Premieres: Hide Upcoming Premieres
Hide Sharing Actions: Hide sharing actions
Hide Chapters: Hide chapters
The app needs to restart for changes to take effect. Restart and apply change?: The