import { SortMeta } from 'primeng/api'
-import { OnInit, ViewChild, Directive } from '@angular/core'
-import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'
+import { Directive, OnInit, ViewChild } from '@angular/core'
import { Notifier, RestPagination, RestTable } from '@app/core'
-import { I18n } from '@ngx-translate/i18n-polyfill'
+import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'
import { ServerBlock } from '@shared/models'
import { BlocklistComponentType, BlocklistService } from './blocklist.service'
@Directive()
+// eslint-disable-next-line @angular-eslint/directive-class-suffix
export class GenericServerBlocklistComponent extends RestTable implements OnInit {
@ViewChild('batchDomainsModal') batchDomainsModal: BatchDomainsModalComponent
- // @ts-ignore: "Abstract methods can only appear within an abstract class"
+ // @ts-expect-error: "Abstract methods can only appear within an abstract class"
public abstract mode: BlocklistComponentType
blockedServers: ServerBlock[] = []
constructor (
protected notifier: Notifier,
- protected blocklistService: BlocklistService,
- protected i18n: I18n
+ protected blocklistService: BlocklistService
) {
super()
}
- // @ts-ignore: "Abstract methods can only appear within an abstract class"
+ // @ts-expect-error: "Abstract methods can only appear within an abstract class"
public abstract getIdentifier (): string
ngOnInit () {
unblockServer (serverBlock: ServerBlock) {
const operation = (host: string) => this.mode === BlocklistComponentType.Account
- ? this.blocklistService.unblockServerByUser(host)
- : this.blocklistService.unblockServerByInstance(host)
+ ? this.blocklistService.unblockServerByUser(host)
+ : this.blocklistService.unblockServerByInstance(host)
const host = serverBlock.blockedServer.host
operation(host).subscribe(
() => {
this.notifier.success(
this.mode === BlocklistComponentType.Account
- ? this.i18n('Instance {{host}} unmuted.', { host })
- : this.i18n('Instance {{host}} unmuted by your instance.', { host })
+ ? $localize`Instance ${host} unmuted.`
+ : $localize`Instance ${host} unmuted by your instance.`
)
- this.loadData()
+ this.reloadData()
}
)
}
() => {
this.notifier.success(
this.mode === BlocklistComponentType.Account
- ? this.i18n('Instance {{domain}} muted.', { domain })
- : this.i18n('Instance {{domain}} muted by your instance.', { domain })
+ ? $localize`Instance ${domain} muted.`
+ : $localize`Instance ${domain} muted by your instance.`
)
- this.loadData()
+ this.reloadData()
}
)
})
}
- protected loadData () {
+ protected reloadData () {
const operation = this.mode === BlocklistComponentType.Account
? this.blocklistService.getUserServerBlocklist({
pagination: this.pagination,
search: this.search
})
- return operation.subscribe(
- resultList => {
+ return operation.subscribe({
+ next: resultList => {
this.blockedServers = resultList.data
this.totalRecords = resultList.total
},
- err => this.notifier.error(err.message)
- )
+ error: err => this.notifier.error(err.message)
+ })
}
}