]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-library/my-videos/my-videos.component.ts
Add channel filters for my videos/followers
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-library / my-videos / my-videos.component.ts
index b1f3baf80148c9f0f5883b0aad8229e185927022..a117d0915dfe9b65a7d0b0d1fb2fb208c20c4eaf 100644 (file)
@@ -9,7 +9,7 @@ import { AdvancedInputFilter } from '@app/shared/shared-forms'
 import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
 import { LiveStreamInformationComponent } from '@app/shared/shared-video-live'
 import { MiniatureDisplayOptions, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature'
-import { VideoSortField } from '@shared/models'
+import { VideoChannel, VideoSortField } from '@shared/models'
 import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component'
 
 @Component({
@@ -47,16 +47,12 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
 
   user: User
 
-  inputFilters: AdvancedInputFilter[] = [
-    {
-      queryParams: { search: 'isLive:true' },
-      label: $localize`Only live videos`
-    }
-  ]
+  inputFilters: AdvancedInputFilter[]
 
   disabled = false
 
   private search: string
+  private userChannels: VideoChannel[] = []
 
   constructor (
     protected router: Router,
@@ -79,6 +75,35 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
     if (this.route.snapshot.queryParams['search']) {
       this.search = this.route.snapshot.queryParams['search']
     }
+
+    this.authService.userInformationLoaded.subscribe(() => {
+      this.user = this.authService.getUser()
+      this.userChannels = this.user.videoChannels
+
+      const channelFilters = this.userChannels.map(c => {
+        return {
+          queryParams: { search: 'channel:' + c.name },
+          label: c.name
+        }
+      })
+
+      this.inputFilters = [
+        {
+          title: $localize`Advanced filters`,
+          children: [
+            {
+              queryParams: { search: 'isLive:true' },
+              label: $localize`Only live videos`
+            }
+          ]
+        },
+
+        {
+          title: $localize`Channel filters`,
+          children: channelFilters
+        }
+      ]
+    })
   }
 
   onSearch (search: string) {
@@ -105,7 +130,12 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
   getVideosObservable (page: number) {
     const newPagination = immutableAssign(this.pagination, { currentPage: page })
 
-    return this.videoService.getMyVideos(newPagination, this.sort, this.search)
+    return this.videoService.getMyVideos({
+      videoPagination: newPagination,
+      sort: this.sort,
+      userChannels: this.userChannels,
+      search: this.search
+    })
       .pipe(
         tap(res => this.pagination.totalItems = res.total)
       )