Skip to content

Commit

Permalink
✨ Add option to exclude short videos from search (#2795)
Browse files Browse the repository at this point in the history
Co-authored-by: iyakushev <[email protected]>
  • Loading branch information
frozenduck and iyakushev committed May 17, 2024
1 parent b4ca3ad commit 1f16f79
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
8 changes: 8 additions & 0 deletions client/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
/>
<SwitchButton
:value="settingsStore.hideShortsFromSearch"
:label="'Hide shorts'"
:small-label="'Do not show shorts in search results'"
:disabled="false"
:right="true"
@valuechange="val => settingsStore.setHideShortsFromSearch(val)"
/>
<SwitchButton
:value="settingsStore.showRecommendedVideos"
:label="'Show recommended videos on a video page'"
Expand Down
5 changes: 5 additions & 0 deletions client/pages/results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BadgeButton from '@/components/buttons/BadgeButton.vue';
import Filters from '@/components/search/Filters.vue';
import SeparatorSmall from '@/components/list/SeparatorSmall.vue';
import { useMessagesStore } from '@/store/messages';
import { useSettingsStore } from '@/store/settings';
const VideoEntry = resolveComponent('ListVideoEntry');
const PlaylistEntry = resolveComponent('ListPlaylistEntry');
Expand All @@ -14,6 +15,7 @@ const Shelf = resolveComponent('SearchShelf');
const route = useRoute();
const messagesStore = useMessagesStore();
const settingsStore = useSettingsStore();
const searchQuery = computed(() => {
const searchParams = new URLSearchParams(route.query as Record<string, string>);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion client/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
);

Expand Down
4 changes: 3 additions & 1 deletion server/src/user/settings/dto/settings.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class SettingsDto {
autoAdjustVideoQuality: boolean;

dashPlaybackEnabled: boolean;

rewriteYouTubeURLs: boolean;

hideShortsFromSearch: boolean;
}
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 @@ -88,6 +88,9 @@ export class Settings extends Document implements SettingsDto {

@Prop()
rewriteYouTubeURLs: boolean;

@Prop()
hideShortsFromSearch: boolean;
}

export const SettingsSchema = SchemaFactory.createForClass(Settings);
3 changes: 2 additions & 1 deletion server/src/user/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export class SettingsService {
sponsorblockSegmentSelfpromo: 'ask',
sponsorblockSegmentSponsor: 'ask',
theme: 'default',
rewriteYouTubeURLs: false
rewriteYouTubeURLs: false,
hideShortsFromSearch: false
};

async setSettings(settings: Partial<SettingsDto>, username: string): Promise<void> {
Expand Down
1 change: 1 addition & 0 deletions shared/api.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export interface components {
autoAdjustVideoQuality: boolean;
dashPlaybackEnabled: boolean;
rewriteYouTubeURLs: boolean;
hideShortsFromSearch: boolean;
};
UserprofileDto: {
username: string;
Expand Down

0 comments on commit 1f16f79

Please sign in to comment.