1 import { Component, OnInit } from '@angular/core'
2 import { Notifier } from '@app/core'
3 import { I18n } from '@ngx-translate/i18n-polyfill'
4 import { RestPagination, RestTable } from '@app/shared'
5 import { SortMeta } from 'primeng/api'
6 import { AccountBlock, BlocklistService } from '@app/shared/blocklist'
9 selector: 'my-account-blocklist',
10 styleUrls: [ './my-account-blocklist.component.scss' ],
11 templateUrl: './my-account-blocklist.component.html'
13 export class MyAccountBlocklistComponent extends RestTable implements OnInit {
14 blockedAccounts: AccountBlock[] = []
16 sort: SortMeta = { field: 'createdAt', order: -1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
20 private notifier: Notifier,
21 private blocklistService: BlocklistService,
32 return 'MyAccountBlocklistComponent'
35 unblockAccount (accountBlock: AccountBlock) {
36 const blockedAccount = accountBlock.blockedAccount
38 this.blocklistService.unblockAccountByUser(blockedAccount)
41 this.notifier.success(this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost }))
48 protected loadData () {
49 return this.blocklistService.getUserAccountBlocklist(this.pagination, this.sort)
52 this.blockedAccounts = resultList.data
53 this.totalRecords = resultList.total
56 err => this.notifier.error(err.message)