diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-22 15:40:13 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 93cae47925e4dd68b7d34a41927b2740b4fab1b4 (patch) | |
tree | f649ab49fab1886b434e164591990cc99b234466 /client/src/app/shared/video/abstract-video-list.ts | |
parent | 587568e1cc0e33c023c1ac62dd28fef313285250 (diff) | |
download | PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.tar.gz PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.tar.zst PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.zip |
Add client hooks
Diffstat (limited to 'client/src/app/shared/video/abstract-video-list.ts')
-rw-r--r-- | client/src/app/shared/video/abstract-video-list.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index cf4b5ef8e..8a247a9af 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts | |||
@@ -13,6 +13,7 @@ import { Notifier, ServerService } from '@app/core' | |||
13 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' | 13 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' |
14 | import { I18n } from '@ngx-translate/i18n-polyfill' | 14 | import { I18n } from '@ngx-translate/i18n-polyfill' |
15 | import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date' | 15 | import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date' |
16 | import { ResultList } from '@shared/models' | ||
16 | 17 | ||
17 | enum GroupDate { | 18 | enum GroupDate { |
18 | UNKNOWN = 0, | 19 | UNKNOWN = 0, |
@@ -73,7 +74,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
73 | private groupedDateLabels: { [id in GroupDate]: string } | 74 | private groupedDateLabels: { [id in GroupDate]: string } |
74 | private groupedDates: { [id: number]: GroupDate } = {} | 75 | private groupedDates: { [id: number]: GroupDate } = {} |
75 | 76 | ||
76 | abstract getVideosObservable (page: number): Observable<{ videos: Video[], totalVideos: number }> | 77 | abstract getVideosObservable (page: number): Observable<ResultList<Video>> |
77 | 78 | ||
78 | abstract generateSyndicationList (): void | 79 | abstract generateSyndicationList (): void |
79 | 80 | ||
@@ -138,12 +139,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
138 | } | 139 | } |
139 | 140 | ||
140 | loadMoreVideos () { | 141 | loadMoreVideos () { |
141 | const observable = this.getVideosObservable(this.pagination.currentPage) | 142 | this.getVideosObservable(this.pagination.currentPage).subscribe( |
142 | 143 | ({ data, total }) => { | |
143 | observable.subscribe( | 144 | this.pagination.totalItems = total |
144 | ({ videos, totalVideos }) => { | 145 | this.videos = this.videos.concat(data) |
145 | this.pagination.totalItems = totalVideos | ||
146 | this.videos = this.videos.concat(videos) | ||
147 | 146 | ||
148 | if (this.groupByDate) this.buildGroupedDateLabels() | 147 | if (this.groupByDate) this.buildGroupedDateLabels() |
149 | 148 | ||