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 import { Subject } from 'rxjs'
9 selector: 'my-account-subscriptions',
10 templateUrl: './my-account-subscriptions.component.html',
11 styleUrls: [ './my-account-subscriptions.component.scss' ]
13 export class MyAccountSubscriptionsComponent implements OnInit {
14 videoChannels: VideoChannel[] = []
16 pagination: ComponentPagination = {
22 onDataSubject = new Subject<any[]>()
25 private userSubscriptionService: UserSubscriptionService,
26 private notifier: Notifier
30 this.loadSubscriptions()
33 loadSubscriptions () {
34 this.userSubscriptionService.listSubscriptions(this.pagination)
37 this.videoChannels = this.videoChannels.concat(res.data)
38 this.pagination.totalItems = res.total
40 this.onDataSubject.next(res.data)
43 error => this.notifier.error(error.message)
49 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
51 this.pagination.currentPage += 1
52 this.loadSubscriptions()