From ff4de38385049bf8f6e1d76d8511854fcfabc71c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 2 Aug 2021 16:50:56 +0200 Subject: Filter videos by live in custom markup --- .../app/shared/shared-main/video/video.service.ts | 34 ++++++++-------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 04a39be0e..4a97719fa 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -210,15 +210,16 @@ export class VideoService implements VideosProvider { } getVideos (parameters: { - videoPagination: ComponentPaginationLight, - sort: VideoSortField, - filter?: VideoFilter, - categoryOneOf?: number[], - languageOneOf?: string[], - skipCount?: boolean, + videoPagination: ComponentPaginationLight + sort: VideoSortField + filter?: VideoFilter + categoryOneOf?: number[] + languageOneOf?: string[] + isLive?: boolean + skipCount?: boolean nsfwPolicy?: NSFWPolicyType }): Observable> { - const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfwPolicy } = parameters + const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfwPolicy, isLive } = parameters const pagination = this.restService.componentPaginationToRestPagination(videoPagination) @@ -228,21 +229,10 @@ export class VideoService implements VideosProvider { if (filter) params = params.set('filter', filter) if (skipCount) params = params.set('skipCount', skipCount + '') - if (nsfwPolicy) { - params = params.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy)) - } - - if (languageOneOf) { - for (const l of languageOneOf) { - params = params.append('languageOneOf[]', l) - } - } - - if (categoryOneOf) { - for (const c of categoryOneOf) { - params = params.append('categoryOneOf[]', c + '') - } - } + if (isLive) params = params.set('isLive', isLive) + if (nsfwPolicy) params = params.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy)) + if (languageOneOf) this.restService.addArrayParams(params, 'languageOneOf', languageOneOf) + if (categoryOneOf) this.restService.addArrayParams(params, 'categoryOneOf', categoryOneOf) return this.authHttp .get>(VideoService.BASE_VIDEO_URL, { params }) -- cgit v1.2.3