X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-search%2Fadvanced-search.model.ts;h=724c4d83498847c08d746e15b68d946d7643de76;hb=8cf43a6524d354fbfa0f0eaf789e8d4756bd25d6;hp=2675c613547436c2c904d17ddc20673b931e1519;hpb=90701ec1d8d27d0072d6b0d2b19362d471484f9a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-search/advanced-search.model.ts b/client/src/app/shared/shared-search/advanced-search.model.ts index 2675c6135..724c4d834 100644 --- a/client/src/app/shared/shared-search/advanced-search.model.ts +++ b/client/src/app/shared/shared-search/advanced-search.model.ts @@ -8,6 +8,8 @@ import { VideosSearchQuery } from '@shared/models' +export type AdvancedSearchResultType = 'videos' | 'playlists' | 'channels' + export class AdvancedSearch { startDate: string // ISO 8601 endDate: string // ISO 8601 @@ -36,6 +38,7 @@ export class AdvancedSearch { sort: string searchTarget: SearchTargetType + resultType: AdvancedSearchResultType // Filters we don't want to count, because they are mandatory private silentFilters = new Set([ 'sort', 'searchTarget' ]) @@ -61,6 +64,7 @@ export class AdvancedSearch { durationMax?: string sort?: string searchTarget?: SearchTargetType + resultType?: AdvancedSearchResultType }) { if (!options) return @@ -84,6 +88,12 @@ export class AdvancedSearch { this.searchTarget = options.searchTarget || undefined + this.resultType = options.resultType || undefined + + if (!this.resultType && this.hasVideoFilter()) { + this.resultType = 'videos' + } + if (isNaN(this.durationMin)) this.durationMin = undefined if (isNaN(this.durationMax)) this.durationMax = undefined @@ -137,7 +147,8 @@ export class AdvancedSearch { isLive: this.isLive, host: this.host, sort: this.sort, - searchTarget: this.searchTarget + searchTarget: this.searchTarget, + resultType: this.resultType } } @@ -199,4 +210,21 @@ export class AdvancedSearch { return true } + + private hasVideoFilter () { + return this.startDate !== undefined || + this.endDate !== undefined || + this.originallyPublishedStartDate !== undefined || + this.originallyPublishedEndDate !== undefined || + this.nsfw !== undefined !== undefined || + this.categoryOneOf !== undefined || + this.licenceOneOf !== undefined || + this.languageOneOf !== undefined || + this.tagsOneOf !== undefined || + this.tagsAllOf !== undefined || + this.durationMin !== undefined || + this.durationMax !== undefined || + this.host !== undefined || + this.isLive !== undefined + } }