1 import { Component, OnInit } from '@angular/core'
2 import { Notifier } from '@app/core'
3 import { SortMeta } from 'primeng/primeng'
4 import { ActorFollow } from '../../../../../../shared/models/actors/follow.model'
5 import { ConfirmService } from '../../../core/confirm/confirm.service'
6 import { RestPagination, RestTable } from '../../../shared'
7 import { FollowService } from '../shared'
8 import { I18n } from '@ngx-translate/i18n-polyfill'
11 selector: 'my-followers-list',
12 templateUrl: './following-list.component.html',
13 styleUrls: [ './following-list.component.scss' ]
15 export class FollowingListComponent extends RestTable implements OnInit {
16 following: ActorFollow[] = []
19 sort: SortMeta = { field: 'createdAt', order: 1 }
20 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
23 private notifier: Notifier,
24 private confirmService: ConfirmService,
25 private followService: FollowService,
35 async removeFollowing (follow: ActorFollow) {
36 const res = await this.confirmService.confirm(
37 this.i18n('Do you really want to unfollow {{host}}?', { host: follow.following.host }),
40 if (res === false) return
42 this.followService.unfollow(follow).subscribe(
44 this.notifier.success(this.i18n('You are not following {{host}} anymore.', { host: follow.following.host }))
48 err => this.notifier.error(err.message)
52 protected loadData () {
53 this.followService.getFollowing(this.pagination, this.sort, this.search)
56 this.following = resultList.data
57 this.totalRecords = resultList.total
60 err => this.notifier.error(err.message)