Prefer using Object.values

This commit is contained in:
Chocobozzz
2022-08-17 15:36:03 +02:00
parent bbd5aa7ead
commit 690bb8f9f3
17 changed files with 48 additions and 48 deletions

View File

@@ -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
}

View File

@@ -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,

View File

@@ -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)