From b3c829cab9d7423a5584c147b4ad848f116ddee1 Mon Sep 17 00:00:00 2001 From: iyakushev Date: Thu, 9 May 2024 21:42:21 -0300 Subject: [PATCH] Added to the settings the option to exclude short videos from search --- client/components/Settings.vue | 8 ++++++++ client/pages/results.vue | 5 +++++ client/store/settings.ts | 3 ++- server/src/user/settings/dto/settings.dto.ts | 4 +++- server/src/user/settings/schemas/settings.schema.ts | 3 +++ server/src/user/settings/settings.service.ts | 3 ++- shared/api.schema.ts | 1 + 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/client/components/Settings.vue b/client/components/Settings.vue index 5df7d5011..e87711cc6 100644 --- a/client/components/Settings.vue +++ b/client/components/Settings.vue @@ -213,6 +213,14 @@ const videoSpeedArray = ['0', '0.25', '0.5', '0.75', '1', '1.25', '1.5', '1.75', :right="true" @valuechange="val => settingsStore.setHideComments(val)" /> + { const searchParams = new URLSearchParams(route.query as Record); @@ -59,6 +61,9 @@ watch(error, newValue => { }); const getListEntryType = (type: string) => { + if (type === 'shorts-shelf' && settingsStore.hideShortsFromSearch) + return null; + switch (type) { case 'video': return VideoEntry; diff --git a/client/store/settings.ts b/client/store/settings.ts index eaa91ce72..ad3c872c8 100644 --- a/client/store/settings.ts +++ b/client/store/settings.ts @@ -54,7 +54,8 @@ export const useSettingsStore = defineStore( sponsorblockSegmentSponsor: 'ask' as SegmentOption, theme: null as ThemeVariant | null, defaultTheme: defaultTheme as ThemeVariant, - rewriteYouTubeURLs: false + rewriteYouTubeURLs: false, + hideShortsFromSearch: false }) ); diff --git a/server/src/user/settings/dto/settings.dto.ts b/server/src/user/settings/dto/settings.dto.ts index d4bfe89a4..3d034b97c 100644 --- a/server/src/user/settings/dto/settings.dto.ts +++ b/server/src/user/settings/dto/settings.dto.ts @@ -52,6 +52,8 @@ export class SettingsDto { autoAdjustVideoQuality: boolean; dashPlaybackEnabled: boolean; - + rewriteYouTubeURLs: boolean; + + hideShortsFromSearch: boolean; } diff --git a/server/src/user/settings/schemas/settings.schema.ts b/server/src/user/settings/schemas/settings.schema.ts index 101107397..1c12dcb57 100644 --- a/server/src/user/settings/schemas/settings.schema.ts +++ b/server/src/user/settings/schemas/settings.schema.ts @@ -88,6 +88,9 @@ export class Settings extends Document implements SettingsDto { @Prop() rewriteYouTubeURLs: boolean; + + @Prop() + hideShortsFromSearch: boolean; } export const SettingsSchema = SchemaFactory.createForClass(Settings); diff --git a/server/src/user/settings/settings.service.ts b/server/src/user/settings/settings.service.ts index bf01e16a7..be49e6763 100644 --- a/server/src/user/settings/settings.service.ts +++ b/server/src/user/settings/settings.service.ts @@ -38,7 +38,8 @@ export class SettingsService { sponsorblockSegmentSelfpromo: 'ask', sponsorblockSegmentSponsor: 'ask', theme: 'default', - rewriteYouTubeURLs: false + rewriteYouTubeURLs: false, + hideShortsFromSearch: false }; async setSettings(settings: Partial, username: string): Promise { diff --git a/shared/api.schema.ts b/shared/api.schema.ts index a06e14262..6c9678dc7 100644 --- a/shared/api.schema.ts +++ b/shared/api.schema.ts @@ -245,6 +245,7 @@ export interface components { autoAdjustVideoQuality: boolean; dashPlaybackEnabled: boolean; rewriteYouTubeURLs: boolean; + hideShortsFromSearch: boolean; }; UserprofileDto: { username: string;