]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/follows/following-list/follow-modal.component.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / following-list / follow-modal.component.ts
index dc69092002714072d7509ea38b64a94d9304f786..8f74e82a66b05923491883115b831ea51d650760 100644 (file)
@@ -1,7 +1,8 @@
 import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
 import { Notifier } from '@app/core'
+import { prepareIcu } from '@app/helpers'
 import { splitAndGetNotEmpty, UNIQUE_HOSTS_OR_HANDLE_VALIDATOR } from '@app/shared/form-validators/host-validators'
-import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
 import { InstanceFollowService } from '@app/shared/shared-instance'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@@ -21,7 +22,7 @@ export class FollowModalComponent extends FormReactive implements OnInit {
   private openedModal: NgbModalRef
 
   constructor (
-    protected formValidatorService: FormValidatorService,
+    protected formReactiveService: FormReactiveService,
     private modalService: NgbModal,
     private followService: InstanceFollowService,
     private notifier: Notifier
@@ -54,16 +55,23 @@ export class FollowModalComponent extends FormReactive implements OnInit {
     return window.location.protocol === 'https:'
   }
 
-  private async addFollowing () {
+  private addFollowing () {
     const hostsOrHandles = splitAndGetNotEmpty(this.form.value['hostsOrHandles'])
 
-    this.followService.follow(hostsOrHandles).subscribe(
-      () => {
-        this.notifier.success($localize`Follow request(s) sent!`)
-        this.newFollow.emit()
-      },
+    this.followService.follow(hostsOrHandles)
+      .subscribe({
+        next: () => {
+          this.notifier.success(
+            prepareIcu($localize`{count, plural, =1 {Follow request sent!} other {Follow requests sent!}}`)(
+              { count: hostsOrHandles.length },
+              $localize`Follow request(s) sent!`
+            )
+          )
 
-      err => this.notifier.error(err.message)
-    )
+          this.newFollow.emit()
+        },
+
+        error: err => this.notifier.error(err.message)
+      })
   }
 }