]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-videos/my-account-videos.component.ts
10 items per page for my videos
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-videos / my-account-videos.component.ts
index 5f29364a857ed78c3e04d85cc3652e4b1b6bc4ab..4aa570363c83f7425f98c4c4b36d7d64f744c092 100644 (file)
@@ -1,6 +1,6 @@
-import { concat, Observable } from 'rxjs'
-import { tap, toArray } from 'rxjs/operators'
-import { Component, ViewChild } from '@angular/core'
+import { concat, Observable, Subject } from 'rxjs'
+import { tap, toArray, debounceTime } from 'rxjs/operators'
+import { Component, ViewChild, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { immutableAssign } from '@app/shared/misc/utils'
 import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
@@ -22,15 +22,15 @@ import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
   templateUrl: './my-account-videos.component.html',
   styleUrls: [ './my-account-videos.component.scss' ]
 })
-export class MyAccountVideosComponent implements DisableForReuseHook {
-  @ViewChild('videosSelection') videosSelection: VideosSelectionComponent
-  @ViewChild('videoChangeOwnershipModal') videoChangeOwnershipModal: VideoChangeOwnershipComponent
+export class MyAccountVideosComponent implements OnInit, DisableForReuseHook {
+  @ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent
+  @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent
 
   titlePage: string
   selection: SelectionType = {}
   pagination: ComponentPagination = {
     currentPage: 1,
-    itemsPerPage: 5,
+    itemsPerPage: 10,
     totalItems: null
   }
   miniatureDisplayOptions: MiniatureDisplayOptions = {
@@ -43,6 +43,8 @@ export class MyAccountVideosComponent implements DisableForReuseHook {
     blacklistInfo: true
   }
   videos: Video[] = []
+  videosSearch: string
+  videosSearchChanged = new Subject<string>()
   getVideosObservableFunction = this.getVideosObservable.bind(this)
 
   constructor (
@@ -59,6 +61,19 @@ export class MyAccountVideosComponent implements DisableForReuseHook {
     this.titlePage = this.i18n('My videos')
   }
 
+  ngOnInit () {
+    this.videosSearchChanged
+      .pipe(
+        debounceTime(500))
+      .subscribe(() => {
+        this.videosSelection.reloadVideos()
+      })
+  }
+
+  onVideosSearchChanged () {
+    this.videosSearchChanged.next()
+  }
+
   disableForReuse () {
     this.videosSelection.disableForReuse()
   }
@@ -70,7 +85,10 @@ export class MyAccountVideosComponent implements DisableForReuseHook {
   getVideosObservable (page: number, sort: VideoSortField) {
     const newPagination = immutableAssign(this.pagination, { currentPage: page })
 
-    return this.videoService.getMyVideos(newPagination, sort)
+    return this.videoService.getMyVideos(newPagination, sort, this.videosSearch)
+      .pipe(
+        tap(res => this.pagination.totalItems = res.total)
+      )
   }
 
   async deleteSelectedVideos () {