Skip to content

Commit

Permalink
✨ Added recommended videos toggle (#2747)
Browse files Browse the repository at this point in the history
  • Loading branch information
nargacu83 authored Apr 6, 2024
1 parent e86d96a commit 9f675b9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions client/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ const videoQualities = ['144p', '240p', '360p', '720p', '1080p', '1440p', '2160p
:right="true"
@valuechange="val => settingsStore.setHideComments(val)"
/>
<SwitchButton
:value="settingsStore.showRecommendedVideos"
:label="'Show recommended videos on a video page'"
:small-label="'Autoplay next video will be ignored for recommended videos.'"
:disabled="false"
:right="true"
@valuechange="val => settingsStore.setShowRecommendedVideos(val)"
/>

<h2><VTIcon name="mdi:television" />Videoplayer</h2>
<div class="settings-dropdown-menu">
Expand Down
8 changes: 4 additions & 4 deletions client/pages/watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const isPlaylist = computed(() => {
});
const isAutoplaying = computed(() => {
return isPlaylist.value || settingsStore.autoplay || route.query.autoplay === 'true';
return isPlaylist.value || (settingsStore.autoplay && !settingsStore.showRecommendedVideos) || route.query.autoplay === 'true';
});
const nextUpVideo = computed(() => {
Expand Down Expand Up @@ -264,7 +264,7 @@ const onVideoEnded = () => {
!videoPlayerStore.loop
) {
playlistSectionRef.value.playNextVideo();
} else if (settingsStore.autoplayNextVideo && video.value.recommendedVideos) {
} else if (settingsStore.autoplayNextVideo && settingsStore.showRecommendedVideos && video.value.recommendedVideos) {
router.push({
path: route.fullPath,
query: { v: video.value.recommendedVideos[0].id, autoplay: 'true' }
Expand Down Expand Up @@ -314,7 +314,7 @@ const watchPageTitle = computed(() => {
@video-ended="onVideoEnded"
/>
<div v-if="video && !videoPending" class="video-meta">
<div class="recommended-videos mobile">
<div v-if="settingsStore.showRecommendedVideos" class="recommended-videos mobile">
<NextUpVideo v-if="nextUpVideo && settingsStore.autoplayNextVideo" :video="nextUpVideo" />
<CollapsibleSection :label="'Recommended videos'" :opened="recommendedOpen">
<RecommendedVideos
Expand Down Expand Up @@ -551,7 +551,7 @@ const watchPageTitle = computed(() => {
width: 100%;
@media screen and (min-width: $mobile-width) {
width: calc(100% - 340px);
width: 100%;
padding: 10px;
}
Expand Down
1 change: 1 addition & 0 deletions client/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const useSettingsStore = defineStore(
settingsSaving: false,
showHomeSubscriptions: true,
showHomeTrendingVideos: true,
showRecommendedVideos: true,
sponsorblockEnabled: true,
sponsorblockSegmentInteraction: 'ask' as SegmentOption,
sponsorblockSegmentIntro: 'ask' as SegmentOption,
Expand Down
2 changes: 2 additions & 0 deletions server/src/user/settings/dto/settings.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class SettingsDto {

showHomeTrendingVideos: boolean;

showRecommendedVideos: boolean;

alwaysLoopVideo: boolean;

hideComments: boolean;
Expand Down
3 changes: 3 additions & 0 deletions server/src/user/settings/schemas/settings.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export class Settings extends Document implements SettingsDto {
@Prop()
showHomeTrendingVideos: boolean;

@Prop()
showRecommendedVideos: boolean;

@Prop()
alwaysLoopVideo: boolean;

Expand Down
1 change: 1 addition & 0 deletions server/src/user/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class SettingsService {
saveVideoHistory: true,
showHomeSubscriptions: true,
showHomeTrendingVideos: true,
showRecommendedVideos: true,
sponsorblockEnabled: true,
sponsorblockSegmentInteraction: 'ask',
sponsorblockSegmentIntro: 'ask',
Expand Down
1 change: 1 addition & 0 deletions shared/api.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export interface components {
saveVideoHistory: boolean;
showHomeSubscriptions: boolean;
showHomeTrendingVideos: boolean;
showRecommendedVideos: boolean;
alwaysLoopVideo: boolean;
hideComments: boolean;
autoplayNextVideo: boolean;
Expand Down

0 comments on commit 9f675b9

Please sign in to comment.