]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-search/advanced-search.model.ts
Add video filters to common video pages
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-search / advanced-search.model.ts
index 9c55f6cd853e0b68d9560911718108e39f707427..2675c613547436c2c904d17ddc20673b931e1519 100644 (file)
@@ -1,3 +1,4 @@
+import { intoArray } from '@app/helpers'
 import {
   BooleanBothQuery,
   BooleanQuery,
@@ -74,8 +75,8 @@ export class AdvancedSearch {
     this.categoryOneOf = options.categoryOneOf || undefined
     this.licenceOneOf = options.licenceOneOf || undefined
     this.languageOneOf = options.languageOneOf || undefined
-    this.tagsOneOf = this.intoArray(options.tagsOneOf)
-    this.tagsAllOf = this.intoArray(options.tagsAllOf)
+    this.tagsOneOf = intoArray(options.tagsOneOf)
+    this.tagsAllOf = intoArray(options.tagsAllOf)
     this.durationMin = parseInt(options.durationMin, 10)
     this.durationMax = parseInt(options.durationMax, 10)
 
@@ -150,9 +151,9 @@ export class AdvancedSearch {
       originallyPublishedStartDate: this.originallyPublishedStartDate,
       originallyPublishedEndDate: this.originallyPublishedEndDate,
       nsfw: this.nsfw,
-      categoryOneOf: this.intoArray(this.categoryOneOf),
-      licenceOneOf: this.intoArray(this.licenceOneOf),
-      languageOneOf: this.intoArray(this.languageOneOf),
+      categoryOneOf: intoArray(this.categoryOneOf),
+      licenceOneOf: intoArray(this.licenceOneOf),
+      languageOneOf: intoArray(this.languageOneOf),
       tagsOneOf: this.tagsOneOf,
       tagsAllOf: this.tagsAllOf,
       durationMin: this.durationMin,
@@ -198,13 +199,4 @@ export class AdvancedSearch {
 
     return true
   }
-
-  private intoArray (value: any) {
-    if (!value) return undefined
-    if (Array.isArray(value)) return value
-
-    if (typeof value === 'string') return value.split(',')
-
-    return [ value ]
-  }
 }