]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-video-miniature/video-filters.model.ts
Deprecate filter video query
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-miniature / video-filters.model.ts
index a3b8129f0a375c1ccb752c357d82073da62f1087..5ad7cf3f7a2bc1281517d0ba94c144d478b7c290 100644 (file)
@@ -1,6 +1,6 @@
 import { intoArray, toBoolean } from '@app/helpers'
 import { AttributesOnly } from '@shared/core-utils'
-import { BooleanBothQuery, NSFWPolicyType, VideoFilter, VideoSortField } from '@shared/models'
+import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoSortField } from '@shared/models'
 
 type VideoFiltersKeys = {
   [ id in keyof AttributesOnly<VideoFilters> ]: any
@@ -38,10 +38,14 @@ export class VideoFilters {
   private onChangeCallbacks: Array<() => void> = []
   private oldFormObjectString: string
 
-  constructor (defaultSort: string, defaultScope: VideoFilterScope) {
+  private readonly hiddenFields: string[] = []
+
+  constructor (defaultSort: string, defaultScope: VideoFilterScope, hiddenFields: string[] = []) {
     this.setDefaultSort(defaultSort)
     this.setDefaultScope(defaultScope)
 
+    this.hiddenFields = hiddenFields
+
     this.reset()
   }
 
@@ -160,6 +164,9 @@ export class VideoFilters {
         label: $localize`VOD videos`
       })
     }
+
+    this.activeFilters = this.activeFilters
+                             .filter(a => this.hiddenFields.includes(a.key) === false)
   }
 
   getActiveFilters () {
@@ -189,14 +196,15 @@ export class VideoFilters {
   }
 
   toVideosAPIObject () {
-    let filter: VideoFilter
-
-    if (this.scope === 'local' && this.allVideos) {
-      filter = 'all-local'
-    } else if (this.scope === 'federated' && this.allVideos) {
-      filter = 'all'
-    } else if (this.scope === 'local') {
-      filter = 'local'
+    let isLocal: boolean
+    let include: VideoInclude
+
+    if (this.scope === 'local') {
+      isLocal = true
+    }
+
+    if (this.allVideos) {
+      include = VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.HIDDEN_PRIVACY
     }
 
     let isLive: boolean
@@ -209,7 +217,8 @@ export class VideoFilters {
       languageOneOf: this.languageOneOf,
       categoryOneOf: this.categoryOneOf,
       search: this.search,
-      filter,
+      isLocal,
+      include,
       isLive
     }
   }