]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-search/advanced-search.model.ts
Fix comment in PR template
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-search / advanced-search.model.ts
index 0e3924841a38fa182c2cbad8b1ba61505d947dec..2c83f53b64c3a12d611b2a10ee2478b76f23fa83 100644 (file)
@@ -1,4 +1,4 @@
-import { BooleanBothQuery, SearchTargetType } from '@shared/models'
+import { BooleanBothQuery, BooleanQuery, SearchTargetType, VideosSearchQuery } from '@shared/models'
 
 export class AdvancedSearch {
   startDate: string // ISO 8601
@@ -21,6 +21,8 @@ export class AdvancedSearch {
   durationMin: number // seconds
   durationMax: number // seconds
 
+  isLive: BooleanQuery
+
   sort: string
 
   searchTarget: SearchTargetType
@@ -41,6 +43,8 @@ export class AdvancedSearch {
     tagsOneOf?: any
     tagsAllOf?: any
 
+    isLive?: BooleanQuery
+
     durationMin?: string
     durationMax?: string
     sort?: string
@@ -54,6 +58,8 @@ export class AdvancedSearch {
     this.originallyPublishedEndDate = options.originallyPublishedEndDate || undefined
 
     this.nsfw = options.nsfw || undefined
+    this.isLive = options.isLive || undefined
+
     this.categoryOneOf = options.categoryOneOf || undefined
     this.licenceOneOf = options.licenceOneOf || undefined
     this.languageOneOf = options.languageOneOf || undefined
@@ -94,6 +100,7 @@ export class AdvancedSearch {
     this.tagsAllOf = undefined
     this.durationMin = undefined
     this.durationMax = undefined
+    this.isLive = undefined
 
     this.sort = '-match'
   }
@@ -112,12 +119,16 @@ export class AdvancedSearch {
       tagsAllOf: this.tagsAllOf,
       durationMin: this.durationMin,
       durationMax: this.durationMax,
+      isLive: this.isLive,
       sort: this.sort,
       searchTarget: this.searchTarget
     }
   }
 
-  toAPIObject () {
+  toAPIObject (): VideosSearchQuery {
+    let isLive: boolean
+    if (this.isLive) isLive = this.isLive === 'true'
+
     return {
       startDate: this.startDate,
       endDate: this.endDate,
@@ -131,6 +142,7 @@ export class AdvancedSearch {
       tagsAllOf: this.tagsAllOf,
       durationMin: this.durationMin,
       durationMax: this.durationMax,
+      isLive,
       sort: this.sort,
       searchTarget: this.searchTarget
     }