aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-library/my-follows/my-subscriptions.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-19 09:44:43 +0200
committerChocobozzz <me@florianbigard.com>2021-10-20 09:25:44 +0200
commit4beda9e12adc7b1f3b178cecd6863ebf3cf431f1 (patch)
tree6244a10b286d66c6dcd7799aee630670d0493781 /client/src/app/+my-library/my-follows/my-subscriptions.component.ts
parent9593a78ae1368a9ad8bb11044fce6fde2892701a (diff)
downloadPeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.tar.gz
PeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.tar.zst
PeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.zip
Add ability to view my followers
Diffstat (limited to 'client/src/app/+my-library/my-follows/my-subscriptions.component.ts')
-rw-r--r--client/src/app/+my-library/my-follows/my-subscriptions.component.ts57
1 files changed, 57 insertions, 0 deletions
diff --git a/client/src/app/+my-library/my-follows/my-subscriptions.component.ts b/client/src/app/+my-library/my-follows/my-subscriptions.component.ts
new file mode 100644
index 000000000..f676aa014
--- /dev/null
+++ b/client/src/app/+my-library/my-follows/my-subscriptions.component.ts
@@ -0,0 +1,57 @@
1import { Subject } from 'rxjs'
2import { Component } from '@angular/core'
3import { ComponentPagination, Notifier } from '@app/core'
4import { VideoChannel } from '@app/shared/shared-main'
5import { UserSubscriptionService } from '@app/shared/shared-user-subscription'
6
7@Component({
8 templateUrl: './my-subscriptions.component.html',
9 styleUrls: [ './my-subscriptions.component.scss' ]
10})
11export class MySubscriptionsComponent {
12 videoChannels: VideoChannel[] = []
13
14 pagination: ComponentPagination = {
15 currentPage: 1,
16 itemsPerPage: 10,
17 totalItems: null
18 }
19
20 onDataSubject = new Subject<any[]>()
21
22 search: string
23
24 constructor (
25 private userSubscriptionService: UserSubscriptionService,
26 private notifier: Notifier
27 ) {}
28
29 onNearOfBottom () {
30 // Last page
31 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
32
33 this.pagination.currentPage += 1
34 this.loadSubscriptions()
35 }
36
37 onSearch (search: string) {
38 this.search = search
39 this.loadSubscriptions(false)
40 }
41
42 private loadSubscriptions (more = true) {
43 this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.search })
44 .subscribe({
45 next: res => {
46 this.videoChannels = more
47 ? this.videoChannels.concat(res.data)
48 : res.data
49 this.pagination.totalItems = res.total
50
51 this.onDataSubject.next(res.data)
52 },
53
54 error: err => this.notifier.error(err.message)
55 })
56 }
57}