X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-moderation%2Fserver-blocklist.component.ts;h=1ba7a1b4d732e33dffc07092d18d93722f055f83;hb=256fb92e67a52a81ebe46ea6f5d4094987cebca7;hp=694b03762df56e41fc85beb066cdcb626613de42;hpb=583eb04b541175035d6d452ca626a96ebf2b7437;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.ts b/client/src/app/shared/shared-moderation/server-blocklist.component.ts index 694b03762..1ba7a1b4d 100644 --- a/client/src/app/shared/shared-moderation/server-blocklist.component.ts +++ b/client/src/app/shared/shared-moderation/server-blocklist.component.ts @@ -1,16 +1,16 @@ 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[] = [] @@ -20,13 +20,12 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit 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 () { @@ -35,19 +34,19 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit 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() } ) } @@ -66,17 +65,17 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit () => { 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, @@ -89,13 +88,13 @@ export class GenericServerBlocklistComponent extends RestTable implements OnInit 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) + }) } }