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 rowsPerPageOptions = [ 20, 50, 100 ]
18 rowsPerPage = this.rowsPerPageOptions[0]
19 sort: SortMeta = { field: 'createdAt', order: -1 }
20 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
23 private notifier: Notifier,
24 private blocklistService: BlocklistService,
35 return 'InstanceAccountBlocklistComponent'
38 switchToDefaultAvatar ($event: Event) {
39 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
42 unblockAccount (accountBlock: AccountBlock) {
43 const blockedAccount = accountBlock.blockedAccount
45 this.blocklistService.unblockAccountByInstance(blockedAccount)
48 this.notifier.success(
49 this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost })
57 protected loadData () {
58 return this.blocklistService.getInstanceAccountBlocklist({
59 pagination: this.pagination,
65 this.blockedAccounts = resultList.data
66 this.totalRecords = resultList.total
69 err => this.notifier.error(err.message)