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 to the settings the option to exclude short videos from search #2795

Merged
merged 1 commit into from
May 17, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
: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 All @@ -238,13 +246,13 @@
<label for="video-speed-input">Default video speed</label>
<div class="video-speed-checkbox">
<label for="as-list" style="padding-right: 5px"> (as list ?)</label>
<CheckBox id="as-list"

Check warning on line 249 in client/components/Settings.vue

View workflow job for this annotation

GitHub Actions / lint:client

Expected a linebreak before this attribute
:value="settingsStore.videoSpeedAsList"
:label="''"
@valuechange="val => settingsStore.setVideoSpeedAsList(val)"
/>
</div>
<input v-if="!settingsStore.videoSpeedAsList"

Check warning on line 255 in client/components/Settings.vue

View workflow job for this annotation

GitHub Actions / lint:client

Expected a linebreak before this attribute
id="video-speed-input"
class="settings-number-input"
type="number"
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