]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts
Add language filters in user preferences
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-subscriptions / my-account-subscriptions.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { Notifier } from '@app/core'
3 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4 import { UserSubscriptionService } from '@app/shared/user-subscription'
5 import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
6
7 @Component({
8 selector: 'my-account-subscriptions',
9 templateUrl: './my-account-subscriptions.component.html',
10 styleUrls: [ './my-account-subscriptions.component.scss' ]
11 })
12 export class MyAccountSubscriptionsComponent implements OnInit {
13 videoChannels: VideoChannel[] = []
14
15 pagination: ComponentPagination = {
16 currentPage: 1,
17 itemsPerPage: 10,
18 totalItems: null
19 }
20
21 constructor (
22 private userSubscriptionService: UserSubscriptionService,
23 private notifier: Notifier
24 ) {}
25
26 ngOnInit () {
27 this.loadSubscriptions()
28 }
29
30 loadSubscriptions () {
31 this.userSubscriptionService.listSubscriptions(this.pagination)
32 .subscribe(
33 res => {
34 this.videoChannels = this.videoChannels.concat(res.data)
35 this.pagination.totalItems = res.total
36 },
37
38 error => this.notifier.error(error.message)
39 )
40 }
41
42 onNearOfBottom () {
43 // Last page
44 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
45
46 this.pagination.currentPage += 1
47 this.loadSubscriptions()
48 }
49
50 }