]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-moderation/account-blocklist.component.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-moderation / account-blocklist.component.ts
index a5a3c27cd0cb279c9d916425425165701831dc00..9ed00bc12f211c0cad3d4a7f560f9588c5284629 100644 (file)
@@ -1,15 +1,13 @@
 import { SortMeta } from 'primeng/api'
-import { OnInit, Directive } from '@angular/core'
+import { Directive, OnInit } from '@angular/core'
 import { Notifier, RestPagination, RestTable } from '@app/core'
-import { Actor } from '@app/shared/shared-main'
-import { I18n } from '@ngx-translate/i18n-polyfill'
 import { AccountBlock } from './account-block.model'
 import { BlocklistComponentType, BlocklistService } from './blocklist.service'
 
 @Directive()
-// tslint:disable-next-line: directive-class-suffix
+// eslint-disable-next-line @angular-eslint/directive-class-suffix
 export class GenericAccountBlocklistComponent extends RestTable implements OnInit {
-  // @ts-ignore: "Abstract methods can only appear within an abstract class"
+  // @ts-expect-error: "Abstract methods can only appear within an abstract class"
   abstract mode: BlocklistComponentType
 
   blockedAccounts: AccountBlock[] = []
@@ -19,23 +17,18 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni
 
   constructor (
     private notifier: Notifier,
-    private blocklistService: BlocklistService,
-    private i18n: I18n
+    private 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"
   abstract getIdentifier (): string
 
   ngOnInit () {
     this.initialize()
   }
 
-  switchToDefaultAvatar ($event: Event) {
-    ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
-  }
-
   unblockAccount (accountBlock: AccountBlock) {
     const blockedAccount = accountBlock.blockedAccount
     const operation = this.mode === BlocklistComponentType.Account
@@ -46,16 +39,16 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni
       () => {
         this.notifier.success(
           this.mode === BlocklistComponentType.Account
-            ? this.i18n('Account {{nameWithHost}} unmuted.', { nameWithHost: blockedAccount.nameWithHost })
-            : this.i18n('Account {{nameWithHost}} unmuted by your instance.', { nameWithHost: blockedAccount.nameWithHost })
+            ? $localize`Account ${blockedAccount.nameWithHost} unmuted.`
+            : $localize`Account ${blockedAccount.nameWithHost} unmuted by your instance.`
         )
 
-        this.loadData()
+        this.reloadData()
       }
     )
   }
 
-  protected loadData () {
+  protected reloadData () {
     const operation = this.mode === BlocklistComponentType.Account
       ? this.blocklistService.getUserAccountBlocklist({
         pagination: this.pagination,
@@ -68,13 +61,13 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni
         search: this.search
       })
 
-    return operation.subscribe(
-      resultList => {
+    return operation.subscribe({
+      next: resultList => {
         this.blockedAccounts = resultList.data
         this.totalRecords = resultList.total
       },
 
-      err => this.notifier.error(err.message)
-    )
+      error: err => this.notifier.error(err.message)
+    })
   }
 }