1 import { SortMeta } from 'primeng/api'
2 import { Component, OnInit, ViewChild } from '@angular/core'
3 import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core'
4 import { InstanceFollowService } from '@app/shared/shared-instance'
5 import { BatchDomainsModalComponent } from '@app/shared/shared-moderation'
6 import { ActorFollow } from '@shared/models'
7 import { FollowModalComponent } from './follow-modal.component'
10 templateUrl: './following-list.component.html',
11 styleUrls: [ '../follows.component.scss', './following-list.component.scss' ]
13 export class FollowingListComponent extends RestTable implements OnInit {
14 @ViewChild('followModal') followModal: FollowModalComponent
16 following: ActorFollow[] = []
18 sort: SortMeta = { field: 'createdAt', order: -1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
22 private notifier: Notifier,
23 private confirmService: ConfirmService,
24 private followService: InstanceFollowService
34 return 'FollowingListComponent'
38 this.followModal.openModal()
41 isInstanceFollowing (follow: ActorFollow) {
42 return follow.following.name === 'peertube'
45 async removeFollowing (follow: ActorFollow) {
46 const res = await this.confirmService.confirm(
47 $localize`Do you really want to unfollow ${follow.following.host}?`,
50 if (res === false) return
52 this.followService.unfollow(follow).subscribe(
54 this.notifier.success($localize`You are not following ${follow.following.host} anymore.`)
58 err => this.notifier.error(err.message)
62 protected reloadData () {
63 this.followService.getFollowing({ pagination: this.pagination, sort: this.sort, search: this.search })
66 this.following = resultList.data
67 this.totalRecords = resultList.total
70 err => this.notifier.error(err.message)