1 import { Component, OnInit } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { SortMeta } from 'primeng/primeng'
4 import { AccountFollow } 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'
14 export class FollowingListComponent extends RestTable implements OnInit {
15 following: AccountFollow[] = []
18 sort: SortMeta = { field: 'createdAt', order: 1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
22 private notificationsService: NotificationsService,
23 private confirmService: ConfirmService,
24 private followService: FollowService,
34 async removeFollowing (follow: AccountFollow) {
35 const res = await this.confirmService.confirm(
36 this.i18n('Do you really want to unfollow {{ host }}?', { host: follow.following.host }),
39 if (res === false) return
41 this.followService.unfollow(follow).subscribe(
43 this.notificationsService.success(
45 this.i18n('You are not following {{ host }} anymore.', { host: follow.following.host })
50 err => this.notificationsService.error(this.i18n('Error'), err.message)
54 protected loadData () {
55 this.followService.getFollowing(this.pagination, this.sort)
58 this.following = resultList.data
59 this.totalRecords = resultList.total
62 err => this.notificationsService.error(this.i18n('Error'), err.message)