Skip to content

Commit

Permalink
* Update play next recommended video setting to be "by default"
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Dec 17, 2024
1 parent ab10d95 commit 6202b60
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class="autoPlayToggle"
:label="$t('Video.Autoplay')"
:compact="true"
:default-value="playNextVideo"
:default-value="playNextRecommendedVideo"
@change="updatePlayNextVideo"
/>
</div>
Expand All @@ -27,14 +27,10 @@
</template>

<script setup>
import { computed } from 'vue'
import FtCard from '../ft-card/ft-card.vue'
import FtListVideoLazy from '../ft-list-video-lazy/ft-list-video-lazy.vue'
import FtToggleSwitch from '../ft-toggle-switch/ft-toggle-switch.vue'
import store from '../../store/index'
defineProps({
data: {
type: Array,
Expand All @@ -43,19 +39,20 @@ defineProps({
showAutoplay: {
type: Boolean,
default: false
}
},
playNextRecommendedVideo: {
type: Boolean,
required: true
},
})
/** @type {import('vue').ComputedRef<boolean>} */
const playNextVideo = computed(() => {
return store.getters.getPlayNextVideo
})
const emit = defineEmits(['play-next-recommended-video-update'])
/**
* @param {boolean} value
*/
function updatePlayNextVideo(value) {
store.dispatch('updatePlayNextVideo', value)
emit('play-next-recommended-video-update', value)
}
</script>

Expand Down
23 changes: 21 additions & 2 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export default defineComponent({
await this.$refs.player.destroyPlayer()
}

// Leave page = no longer remember the value
sessionStorage.removeItem('Watch/playNextRecommendedVideo')

next()
},
data: function () {
Expand Down Expand Up @@ -110,6 +113,7 @@ export default defineComponent({
captions: [],
/** @type {'EQUIRECTANGULAR' | 'EQUIRECTANGULAR_THREED_TOP_BOTTOM' | 'MESH'| null} */
vrProjection: null,
playNextRecommendedVideo: false,
recommendedVideos: [],
downloadLinks: [],
watchingPlaylist: false,
Expand Down Expand Up @@ -179,9 +183,17 @@ export default defineComponent({
thumbnailPreference: function () {
return this.$store.getters.getThumbnailPreference
},
playNextVideo: function () {
playNextRecommendedVideoByDefault: function () {
return this.$store.getters.getPlayNextVideo
},
playNextRecommendedVideoForThisSession: function () {
const oldValue = sessionStorage.getItem('Watch/playNextRecommendedVideo')
if (oldValue !== null) {
return oldValue === 'true'
}

return this.playNextRecommendedVideoByDefault
},
autoplayPlaylists: function () {
return this.$store.getters.getAutoplayPlaylists
},
Expand Down Expand Up @@ -302,6 +314,8 @@ export default defineComponent({
created: function () {
this.videoId = this.$route.params.id
this.activeFormat = this.defaultVideoFormat
// So that the value for this session remains unchanged even if setting changed
this.updatePlayNextRecommendedVideoForThisSession(this.playNextRecommendedVideoForThisSession)

this.checkIfTimestamp()
},
Expand Down Expand Up @@ -1242,7 +1256,7 @@ export default defineComponent({
},

handleVideoEnded: function () {
if ((!this.watchingPlaylist || !this.autoplayPlaylists) && !this.playNextVideo) {
if ((!this.watchingPlaylist || !this.autoplayPlaylists) && !this.playNextRecommendedVideo) {
return
}

Expand Down Expand Up @@ -1670,6 +1684,11 @@ export default defineComponent({
this.blockVideoAutoplay = false
},

updatePlayNextRecommendedVideoForThisSession(value) {
this.playNextRecommendedVideo = value
sessionStorage.setItem('Watch/playNextRecommendedVideo', value.toString())
},

...mapActions([
'setAppTitle',
'updateHistory',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/views/Watch/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,14 @@
v-if="!isLoading && !hideRecommendedVideos"
:show-autoplay="!watchingPlaylist"
:data="recommendedVideos"
:play-next-recommended-video="playNextRecommendedVideo"
class="watchVideoSideBar watchVideoRecommendations"
:class="{
theatreRecommendations: useTheatreMode,
watchVideoRecommendationsLowerCard: watchingPlaylist || isLive,
watchVideoRecommendationsNoCard: !watchingPlaylist || !isLive
}"
@play-next-recommended-video-update="updatePlayNextRecommendedVideoForThisSession"
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion static/locales/en-GB.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Settings:
Hide FreeTube Header Logo: Hide FreeTube header logo
Player Settings:
Player Settings: 'Player'
Play Next Video: 'Play next video'
Play Next Video: 'Autoplay Recommended Videos by Default'
Turn on Subtitles by Default: 'Turn on subtitles by default'
Autoplay Videos: 'Autoplay Videos'
Proxy Videos Through Invidious: 'Proxy Videos Through Invidious'
Expand Down
2 changes: 1 addition & 1 deletion static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ Settings:
#* Main Color Theme
Player Settings:
Player Settings: Player
Play Next Video: Play Next Video
Play Next Video: Autoplay Recommended Videos by Default
Turn on Subtitles by Default: Turn on Subtitles by Default
Autoplay Videos: Autoplay Videos
Proxy Videos Through Invidious: Proxy Videos Through Invidious
Expand Down

0 comments on commit 6202b60

Please sign in to comment.