X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-video-miniature%2Fvideo-filters.model.ts;h=73a30ca080bcdc20dc45bb3e2389a2656519bd7e;hb=3545e72c686ff1725bbdfd8d16d693e2f4aa75a3;hp=a3b8129f0a375c1ccb752c357d82073da62f1087;hpb=fdec51e3846d50e3375612a6820ed3ab0b5fcd25;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-video-miniature/video-filters.model.ts b/client/src/app/shared/shared-video-miniature/video-filters.model.ts index a3b8129f0..73a30ca08 100644 --- a/client/src/app/shared/shared-video-miniature/video-filters.model.ts +++ b/client/src/app/shared/shared-video-miniature/video-filters.model.ts @@ -1,6 +1,7 @@ -import { intoArray, toBoolean } from '@app/helpers' -import { AttributesOnly } from '@shared/core-utils' -import { BooleanBothQuery, NSFWPolicyType, VideoFilter, VideoSortField } from '@shared/models' +import { splitIntoArray, toBoolean } from '@app/helpers' +import { getAllPrivacies } from '@shared/core-utils' +import { AttributesOnly } from '@shared/typescript-utils' +import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models' type VideoFiltersKeys = { [ id in keyof AttributesOnly ]: any @@ -38,10 +39,14 @@ export class VideoFilters { private onChangeCallbacks: Array<() => void> = [] private oldFormObjectString: string - constructor (defaultSort: string, defaultScope: VideoFilterScope) { + private readonly hiddenFields: string[] = [] + + constructor (defaultSort: string, defaultScope: VideoFilterScope, hiddenFields: string[] = []) { this.setDefaultSort(defaultSort) this.setDefaultScope(defaultScope) + this.hiddenFields = hiddenFields + this.reset() } @@ -89,8 +94,8 @@ export class VideoFilters { if (obj.nsfw !== undefined) this.nsfw = obj.nsfw - if (obj.languageOneOf !== undefined) this.languageOneOf = intoArray(obj.languageOneOf) - if (obj.categoryOneOf !== undefined) this.categoryOneOf = intoArray(obj.categoryOneOf) + if (obj.languageOneOf !== undefined) this.languageOneOf = splitIntoArray(obj.languageOneOf) + if (obj.categoryOneOf !== undefined) this.categoryOneOf = splitIntoArray(obj.categoryOneOf) if (obj.scope !== undefined) this.scope = obj.scope if (obj.allVideos !== undefined) this.allVideos = toBoolean(obj.allVideos) @@ -160,6 +165,9 @@ export class VideoFilters { label: $localize`VOD videos` }) } + + this.activeFilters = this.activeFilters + .filter(a => this.hiddenFields.includes(a.key) === false) } getActiveFilters () { @@ -189,14 +197,17 @@ export class VideoFilters { } toVideosAPIObject () { - let filter: VideoFilter - - if (this.scope === 'local' && this.allVideos) { - filter = 'all-local' - } else if (this.scope === 'federated' && this.allVideos) { - filter = 'all' - } else if (this.scope === 'local') { - filter = 'local' + let isLocal: boolean + let include: VideoInclude + let privacyOneOf: VideoPrivacy[] + + if (this.scope === 'local') { + isLocal = true + } + + if (this.allVideos) { + include = VideoInclude.NOT_PUBLISHED_STATE + privacyOneOf = getAllPrivacies() } let isLive: boolean @@ -209,7 +220,9 @@ export class VideoFilters { languageOneOf: this.languageOneOf, categoryOneOf: this.categoryOneOf, search: this.search, - filter, + isLocal, + include, + privacyOneOf, isLive } }