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'
10 selector: 'my-followers-list',
11 templateUrl: './following-list.component.html'
13 export class FollowingListComponent extends RestTable implements OnInit {
14 following: AccountFollow[] = []
17 sort: SortMeta = { field: 'createdAt', order: 1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
21 private notificationsService: NotificationsService,
22 private confirmService: ConfirmService,
23 private followService: FollowService
32 async removeFollowing (follow: AccountFollow) {
33 const res = await this.confirmService.confirm(`Do you really want to unfollow ${follow.following.host}?`, 'Unfollow')
34 if (res === false) return
36 this.followService.unfollow(follow).subscribe(
38 this.notificationsService.success('Success', `You are not following ${follow.following.host} anymore.`)
42 err => this.notificationsService.error('Error', err.message)
46 protected loadData () {
47 this.followService.getFollowing(this.pagination, this.sort)
50 this.following = resultList.data
51 this.totalRecords = resultList.total
54 err => this.notificationsService.error('Error', err.message)