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 { ActorFollow } from '@shared/models'
6 import { FollowModalComponent } from './follow-modal.component'
9 templateUrl: './following-list.component.html',
10 styleUrls: [ '../follows.component.scss', './following-list.component.scss' ]
12 export class FollowingListComponent extends RestTable implements OnInit {
13 @ViewChild('followModal') followModal: FollowModalComponent
15 following: ActorFollow[] = []
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
21 private notifier: Notifier,
22 private confirmService: ConfirmService,
23 private followService: InstanceFollowService
33 return 'FollowingListComponent'
37 this.followModal.openModal()
40 isInstanceFollowing (follow: ActorFollow) {
41 return follow.following.name === 'peertube'
44 async removeFollowing (follow: ActorFollow) {
45 const res = await this.confirmService.confirm(
46 $localize`Do you really want to unfollow ${follow.following.host}?`,
49 if (res === false) return
51 this.followService.unfollow(follow)
54 this.notifier.success($localize`You are not following ${follow.following.host} anymore.`)
58 error: 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 error: err => this.notifier.error(err.message)