]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/video/abstract-video-list.ts
Add client hooks
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / abstract-video-list.ts
index cf4b5ef8eb85e78050c021b3eedefa4402ecf405..8a247a9af726c87fac3c3970216c355ba2ff4063 100644 (file)
@@ -13,6 +13,7 @@ import { Notifier, ServerService } from '@app/core'
 import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
 import { I18n } from '@ngx-translate/i18n-polyfill'
 import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date'
+import { ResultList } from '@shared/models'
 
 enum GroupDate {
   UNKNOWN = 0,
@@ -73,7 +74,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
   private groupedDateLabels: { [id in GroupDate]: string }
   private groupedDates: { [id: number]: GroupDate } = {}
 
-  abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number }>
+  abstract getVideosObservable (page: number): Observable<ResultList<Video>>
 
   abstract generateSyndicationList (): void
 
@@ -138,12 +139,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
   }
 
   loadMoreVideos () {
-    const observable = this.getVideosObservable(this.pagination.currentPage)
-
-    observable.subscribe(
-      ({ videos, totalVideos }) => {
-        this.pagination.totalItems = totalVideos
-        this.videos = this.videos.concat(videos)
+    this.getVideosObservable(this.pagination.currentPage).subscribe(
+      ({ data, total }) => {
+        this.pagination.totalItems = total
+        this.videos = this.videos.concat(data)
 
         if (this.groupByDate) this.buildGroupedDateLabels()