From 690bb8f9f3413147a4f71d5ff0a3cd8170a94ce3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 17 Aug 2022 15:36:03 +0200 Subject: Prefer using Object.values --- client/src/app/helpers/utils/object.ts | 4 ++-- client/src/app/shared/shared-search/advanced-search.model.ts | 12 ++++++------ .../app/shared/shared-video-miniature/video-filters.model.ts | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'client/src') diff --git a/client/src/app/helpers/utils/object.ts b/client/src/app/helpers/utils/object.ts index 1ca4a23ac..69b2b18c0 100644 --- a/client/src/app/helpers/utils/object.ts +++ b/client/src/app/helpers/utils/object.ts @@ -18,7 +18,7 @@ function sortBy (obj: any[], key1: string, key2?: string) { }) } -function intoArray (value: any) { +function splitIntoArray (value: any) { if (!value) return undefined if (Array.isArray(value)) return value @@ -42,6 +42,6 @@ export { sortBy, immutableAssign, removeElementFromArray, - intoArray, + splitIntoArray, toBoolean } 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 ea9baa27f..e8bb00fd3 100644 --- a/client/src/app/shared/shared-search/advanced-search.model.ts +++ b/client/src/app/shared/shared-search/advanced-search.model.ts @@ -1,4 +1,4 @@ -import { intoArray } from '@app/helpers' +import { splitIntoArray } from '@app/helpers' import { BooleanBothQuery, BooleanQuery, @@ -76,8 +76,8 @@ export class AdvancedSearch { this.categoryOneOf = options.categoryOneOf || undefined this.licenceOneOf = options.licenceOneOf || undefined this.languageOneOf = options.languageOneOf || undefined - this.tagsOneOf = intoArray(options.tagsOneOf) - this.tagsAllOf = intoArray(options.tagsAllOf) + this.tagsOneOf = splitIntoArray(options.tagsOneOf) + this.tagsAllOf = splitIntoArray(options.tagsAllOf) this.durationMin = options.durationMin ? parseInt(options.durationMin, 10) : undefined this.durationMax = options.durationMax ? parseInt(options.durationMax, 10) : undefined @@ -152,9 +152,9 @@ export class AdvancedSearch { originallyPublishedStartDate: this.originallyPublishedStartDate, originallyPublishedEndDate: this.originallyPublishedEndDate, nsfw: this.nsfw, - categoryOneOf: intoArray(this.categoryOneOf), - licenceOneOf: intoArray(this.licenceOneOf), - languageOneOf: intoArray(this.languageOneOf), + categoryOneOf: splitIntoArray(this.categoryOneOf), + licenceOneOf: splitIntoArray(this.licenceOneOf), + languageOneOf: splitIntoArray(this.languageOneOf), tagsOneOf: this.tagsOneOf, tagsAllOf: this.tagsAllOf, durationMin: this.durationMin, 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 8ad2fcd5d..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,4 +1,4 @@ -import { intoArray, toBoolean } from '@app/helpers' +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' @@ -94,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) -- cgit v1.2.3