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'
7 import { Actor } from '@app/shared/actor/actor.model'
10 selector: 'my-instance-account-blocklist',
11 styleUrls: [ '../moderation.component.scss', './instance-account-blocklist.component.scss' ],
12 templateUrl: './instance-account-blocklist.component.html'
14 export class InstanceAccountBlocklistComponent extends RestTable implements OnInit {
15 blockedAccounts: AccountBlock[] = []
17 sort: SortMeta = { field: 'createdAt', order: -1 }
18 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
21 private notifier: Notifier,
22 private blocklistService: BlocklistService,
33 return 'InstanceAccountBlocklistComponent'
36 switchToDefaultAvatar ($event: Event) {
37 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
40 unblockAccount (accountBlock: AccountBlock) {
41 const blockedAccount = accountBlock.blockedAccount
43 this.blocklistService.unblockAccountByInstance(blockedAccount)
46 this.notifier.success(
47 this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost })
55 protected loadData () {
56 return this.blocklistService.getInstanceAccountBlocklist({
57 pagination: this.pagination,
63 this.blockedAccounts = resultList.data
64 this.totalRecords = resultList.total
67 err => this.notifier.error(err.message)