aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-subscriptions
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-24 10:31:56 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commitaa55a4da422330fe2816f1764b64f6607a0ca4aa (patch)
tree39933a835cc13a685696178e374fe3ac8ba9003b /client/src/app/+my-account/my-account-subscriptions
parentf37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9 (diff)
downloadPeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.tar.gz
PeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.tar.zst
PeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.zip
Infinite scroll to list our subscriptions
Diffstat (limited to 'client/src/app/+my-account/my-account-subscriptions')
-rw-r--r--client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html2
-rw-r--r--client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts32
2 files changed, 28 insertions, 6 deletions
diff --git a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html
index 4c68cd1a5..3752de49f 100644
--- a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html
+++ b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html
@@ -1,4 +1,4 @@
1<div class="video-channels"> 1<div class="video-channels" myInfiniteScroller [autoInit]="true" (nearOfBottom)="onNearOfBottom()">
2 <div *ngFor="let videoChannel of videoChannels" class="video-channel"> 2 <div *ngFor="let videoChannel of videoChannels" class="video-channel">
3 <a [routerLink]="[ '/video-channels', videoChannel.name ]"> 3 <a [routerLink]="[ '/video-channels', videoChannel.name ]">
4 <img [src]="videoChannel.avatarUrl" alt="Avatar" /> 4 <img [src]="videoChannel.avatarUrl" alt="Avatar" />
diff --git a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts
index 9434b196f..9517a3705 100644
--- a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts
+++ b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts
@@ -3,6 +3,7 @@ import { NotificationsService } from 'angular2-notifications'
3import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 3import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4import { I18n } from '@ngx-translate/i18n-polyfill' 4import { I18n } from '@ngx-translate/i18n-polyfill'
5import { UserSubscriptionService } from '@app/shared/user-subscription' 5import { UserSubscriptionService } from '@app/shared/user-subscription'
6import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
6 7
7@Component({ 8@Component({
8 selector: 'my-account-subscriptions', 9 selector: 'my-account-subscriptions',
@@ -12,6 +13,12 @@ import { UserSubscriptionService } from '@app/shared/user-subscription'
12export class MyAccountSubscriptionsComponent implements OnInit { 13export class MyAccountSubscriptionsComponent implements OnInit {
13 videoChannels: VideoChannel[] = [] 14 videoChannels: VideoChannel[] = []
14 15
16 pagination: ComponentPagination = {
17 currentPage: 1,
18 itemsPerPage: 10,
19 totalItems: null
20 }
21
15 constructor ( 22 constructor (
16 private userSubscriptionService: UserSubscriptionService, 23 private userSubscriptionService: UserSubscriptionService,
17 private notificationsService: NotificationsService, 24 private notificationsService: NotificationsService,
@@ -19,12 +26,27 @@ export class MyAccountSubscriptionsComponent implements OnInit {
19 ) {} 26 ) {}
20 27
21 ngOnInit () { 28 ngOnInit () {
22 this.userSubscriptionService.listSubscriptions() 29 this.loadSubscriptions()
23 .subscribe( 30 }
24 res => this.videoChannels = res.data, 31
32 loadSubscriptions () {
33 this.userSubscriptionService.listSubscriptions(this.pagination)
34 .subscribe(
35 res => {
36 this.videoChannels = this.videoChannels.concat(res.data)
37 this.pagination.totalItems = res.total
38 },
39
40 error => this.notificationsService.error(this.i18n('Error'), error.message)
41 )
42 }
43
44 onNearOfBottom () {
45 // Last page
46 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
25 47
26 error => this.notificationsService.error(this.i18n('Error'), error.message) 48 this.pagination.currentPage += 1
27 ) 49 this.loadSubscriptions()
28 } 50 }
29 51
30} 52}