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 { InstanceFollowService } from '@app/shared/shared-instance'
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} 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)
+ })
}
}