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 trending toggle in client settings #2735

Merged
merged 7 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions client/components/Logo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<nuxt-link class="logo-link" to="/">
<h1 class="logo">
<span>View</span>
<span class="logo-colored">Tube</span>
</h1>
<img class="logo-small" src="@/assets/icon.svg" alt="ViewTube" />
</nuxt-link>
</template>

<style lang="scss">
.logo-link {
text-decoration: none;
margin: auto 10px auto 10px;
box-sizing: border-box;
display: flex;
flex-direction: row-reverse;
align-items: center;
position: relative;
z-index: +1;
.logo {
font-family: $header-font;
font-size: 1.5rem;
color: var(--title-color);
width: auto;
overflow: hidden;
white-space: nowrap;
transition: width 300ms linear;
display: flex;
margin: 4px 0 0 0;
span {
display: block;
}
.logo-colored {
color: transparent;
background-image: var(--theme-color-gradient);
background-clip: text;
-webkit-background-clip: text;
}
}
.logo-small {
margin: auto;
height: calc(#{$header-height} - 20px);
transform: scale(0.8) translateY(-2px);
transition: clip-path 300ms $intro-easing, transform 300ms linear;
}
}
</style>
16 changes: 16 additions & 0 deletions client/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ const videoQualities = ['144p', '240p', '360p', '720p', '1080p', '1440p', '2160p
@valuechange="val => settingsStore.setShowHomeSubscriptions(val)"
/>

<SwitchButton
:value="settingsStore.showHomeTrendingVideos"
:label="'Show trending videos on home screen'"
:disabled="false"
:right="true"
@valuechange="val => settingsStore.setShowHomeTrendingVideos(val)"
/>

<h2><VTIcon name="mdi:auto-fix" />Enhancements</h2>
<SwitchButton
:value="settingsStore.rewriteYouTubeURLs"
Expand All @@ -195,6 +203,14 @@ const videoQualities = ['144p', '240p', '360p', '720p', '1080p', '1440p', '2160p
:right="true"
@valuechange="val => settingsStore.setRewriteYouTubeURLs(val)"
/>
<SwitchButton
:value="settingsStore.hideComments"
:label="'Hide comments'"
:small-label="'Do not load and do not show comments on videos'"
:disabled="false"
:right="true"
@valuechange="val => settingsStore.setHideComments(val)"
/>

<h2><VTIcon name="mdi:television" />Videoplayer</h2>
<div class="settings-dropdown-menu">
Expand Down
64 changes: 12 additions & 52 deletions client/components/header/MainHeader.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<script setup lang="ts">
import Logo from '@/components/Logo.vue';
import MainSearchBox from '@/components/MainSearchBox.vue';
import UserMenu from '@/components/header/UserMenu.vue';
import { useSettingsStore } from '@/store/settings';
import { useUserStore } from '@/store/user';
const settingsStore = useSettingsStore();
const userStore = useUserStore();
const route = useRoute();
const { posAbsolute, topPositionPx } = useHeaderScroll();
</script>

<template>
<div class="header" :class="{ absolute: posAbsolute }">
<nuxt-link class="logo-link" to="/">
<h1 class="logo">
<span>View</span>
<span class="logo-colored">Tube</span>
</h1>
<img class="logo-small" src="@/assets/icon.svg" alt="ViewTube" />
</nuxt-link>
<MainSearchBox />
<Logo v-if="route.fullPath !== '/' || ((userStore.isLoggedIn && settingsStore.showHomeSubscriptions) || settingsStore.showHomeTrendingVideos)" />
<MainSearchBox v-if="route.fullPath !== '/' || ((userStore.isLoggedIn && settingsStore.showHomeSubscriptions) || settingsStore.showHomeTrendingVideos)" />
<UserMenu />
</div>
</template>
Expand All @@ -28,7 +27,7 @@ const { posAbsolute, topPositionPx } = useHeaderScroll();
left: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
justify-content: right;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was needed because when we hide the Logo and the MainSearchBox, the UserMenu was on the left side of the header bar.

z-index: 800;
background-color: var(--header-transparent);
backdrop-filter: blur(10px);
Expand All @@ -51,49 +50,10 @@ const { posAbsolute, topPositionPx } = useHeaderScroll();
position: absolute;
}
.logo-link {
text-decoration: none;
margin: auto 10px auto 10px;
box-sizing: border-box;
display: flex;
flex-direction: row-reverse;
align-items: center;
position: relative;
z-index: +1;
.logo {
font-family: $header-font;
font-size: 1.5rem;
color: var(--title-color);
width: auto;
overflow: hidden;
white-space: nowrap;
transition: width 300ms linear;
display: flex;
margin: 4px 0 0 0;
span {
display: block;
}
.logo-colored {
color: transparent;
background-image: var(--theme-color-gradient);
background-clip: text;
-webkit-background-clip: text;
}
}
.logo-small {
margin: auto;
height: calc(#{$header-height} - 20px);
transform: scale(0.8) translateY(-2px);
transition: clip-path 300ms $intro-easing, transform 300ms linear;
}
@media screen and (max-width: $mobile-width) {
@media screen and (max-width: $mobile-width) {
.logo-link {
width: 40px;
.logo {
width: 0;
}
Expand Down
29 changes: 28 additions & 1 deletion client/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { useUserStore } from '@/store/user';
import { useSettingsStore } from '@/store/settings';
import Logo from '@/components/Logo.vue';
const settingsStore = useSettingsStore();
const userStore = useUserStore();
Expand All @@ -19,10 +20,18 @@ const { data: homeFeedData, error: homeFeedError, pending: homeFeedLoading } = u
<ErrorPage v-if="homeFeedError" text="Error loading homepage. The API may not be reachable." />
<HomeSubscriptions v-if="userStore.isLoggedIn && settingsStore.showHomeSubscriptions" />
<HomeVideosContainer
v-if="homeFeedData?.videos"
v-if="settingsStore.showHomeTrendingVideos && homeFeedData?.videos"
:videos="homeFeedData?.videos"
:short="settingsStore.showHomeSubscriptions"
/>

<div
v-if="!(userStore.isLoggedIn && settingsStore.showHomeSubscriptions) && !settingsStore.showHomeTrendingVideos"
class="home-search-container centered">

<Logo />
<MainSearchBox />
</div>
</div>
</template>

Expand Down Expand Up @@ -67,5 +76,23 @@ const { data: homeFeedData, error: homeFeedError, pending: homeFeedLoading } = u
display: grid;
justify-items: center;
}
.home-search-container {
display: flex;
flex-direction: column;
justify-content: center;
width: calc(100% - 50px);
max-width: $search-box-width;
&.centered {
top: calc(50% - $header-height);
}
.logo-link {
justify-content: center;
margin: 10px auto;
}
}
}
</style>
8 changes: 5 additions & 3 deletions client/pages/watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ watch(
if (newValue.v !== oldValue.v || newValue.list !== oldValue.list) {
refresh();
const videoId = newValue.v as string;
loadComments(videoId);
if (!settingsStore.hideComments)
loadComments(videoId);
}
}
);
Expand All @@ -249,7 +250,8 @@ onMounted(() => {
if (window && window.innerWidth > 700) {
recommendedOpen.value = true;
}
loadComments();
if (!settingsStore.hideComments)
loadComments();
loadDislikes();
loadPlaylist();
});
Expand Down Expand Up @@ -426,7 +428,7 @@ const watchPageTitle = computed(() => {
</div>
</div>

<div class="comments-description">
<div v-if="!settingsStore.hideComments" class="comments-description">
<div
class="video-infobox-description links"
v-html="createTextLinks(video.description)"
Expand Down
2 changes: 2 additions & 0 deletions client/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const useSettingsStore = defineStore(
const state = toRefs(
reactive({
alwaysLoopVideo: false,
hideComments: false,
audioModeDefault: false,
autoAdjustAudioQuality: true,
autoAdjustVideoQuality: true,
Expand All @@ -40,6 +41,7 @@ export const useSettingsStore = defineStore(
saveVideoHistory: true,
settingsSaving: false,
showHomeSubscriptions: true,
showHomeTrendingVideos: true,
sponsorblockEnabled: true,
sponsorblockSegmentInteraction: 'ask' as SegmentOption,
sponsorblockSegmentIntro: 'ask' as SegmentOption,
Expand Down
4 changes: 4 additions & 0 deletions server/src/user/settings/dto/settings.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ export class SettingsDto {

showHomeSubscriptions: boolean;

showHomeTrendingVideos: boolean;

alwaysLoopVideo: boolean;

hideComments: boolean;

autoplayNextVideo: boolean;

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

@Prop()
showHomeTrendingVideos: boolean;

@Prop()
alwaysLoopVideo: boolean;

@Prop()
hideComments: boolean;

@Prop()
autoplayNextVideo: boolean;

Expand Down
2 changes: 2 additions & 0 deletions server/src/user/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class SettingsService {

private defaultOptions: SettingsDto = {
alwaysLoopVideo: false,
hideComments: false,
audioModeDefault: false,
autoAdjustAudioQuality: true,
autoAdjustVideoQuality: true,
Expand All @@ -25,6 +26,7 @@ export class SettingsService {
defaultVideoSpeed: 1,
saveVideoHistory: true,
showHomeSubscriptions: true,
showHomeTrendingVideos: true,
sponsorblockEnabled: true,
sponsorblockSegmentInteraction: 'ask',
sponsorblockSegmentIntro: 'ask',
Expand Down
2 changes: 2 additions & 0 deletions shared/api.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ export interface components {
autoplay: boolean;
saveVideoHistory: boolean;
showHomeSubscriptions: boolean;
showHomeTrendingVideos: boolean;
alwaysLoopVideo: boolean;
hideComments: boolean;
autoplayNextVideo: boolean;
audioModeDefault: boolean;
defaultVideoSpeed: number;
Expand Down
Loading