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-instance-account-blocklist',
10 styleUrls: [ '../moderation.component.scss', './instance-account-blocklist.component.scss' ],
11 templateUrl: './instance-account-blocklist.component.html'
13 export class InstanceAccountBlocklistComponent extends RestTable implements OnInit {
14 blockedAccounts: AccountBlock[] = []
16 rowsPerPageOptions = [ 20, 50, 100 ]
17 rowsPerPage = this.rowsPerPageOptions[0]
18 sort: SortMeta = { field: 'createdAt', order: -1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
22 private notifier: Notifier,
23 private blocklistService: BlocklistService,
34 return 'InstanceAccountBlocklistComponent'
37 unblockAccount (accountBlock: AccountBlock) {
38 const blockedAccount = accountBlock.blockedAccount
40 this.blocklistService.unblockAccountByInstance(blockedAccount)
43 this.notifier.success(
44 this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost })
52 protected loadData () {
53 return this.blocklistService.getInstanceAccountBlocklist({
54 pagination: this.pagination,
60 this.blockedAccounts = resultList.data
61 this.totalRecords = resultList.total
64 err => this.notifier.error(err.message)