]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-library/my-ownership/my-accept-ownership/my-accept-ownership.component.ts
Refactor form reactive
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-library / my-ownership / my-accept-ownership / my-accept-ownership.component.ts
index 7889d0985177eaa60076894a788f06bd30c83c9f..ca7eb680b6fe25cfc392b6dca20a042a5f067529 100644 (file)
@@ -1,9 +1,9 @@
 import { SelectChannelItem } from 'src/types/select-options-item.model'
 import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
 import { AuthService, Notifier } from '@app/core'
-import { listUserChannels } from '@app/helpers'
+import { listUserChannelsForSelect } from '@app/helpers'
 import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
-import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormReactiveService } from '@app/shared/shared-forms'
 import { VideoOwnershipService } from '@app/shared/shared-main'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { VideoChangeOwnership } from '@shared/models'
@@ -24,19 +24,19 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
   error: string = null
 
   constructor (
-    protected formValidatorService: FormValidatorService,
+    protected formReactiveService: FormReactiveService,
     private videoOwnershipService: VideoOwnershipService,
     private notifier: Notifier,
     private authService: AuthService,
     private modalService: NgbModal
-    ) {
+  ) {
     super()
   }
 
   ngOnInit () {
     this.videoChannels = []
 
-    listUserChannels(this.authService)
+    listUserChannelsForSelect(this.authService)
       .subscribe(channels => this.videoChannels = channels)
 
     this.buildForm({
@@ -64,14 +64,14 @@ export class MyAcceptOwnershipComponent extends FormReactive implements OnInit {
     const videoChangeOwnership = this.videoChangeOwnership
     this.videoOwnershipService
       .acceptOwnership(videoChangeOwnership.id, { channelId: channel })
-      .subscribe(
-        () => {
+      .subscribe({
+        next: () => {
           this.notifier.success($localize`Ownership accepted`)
           if (this.accepted) this.accepted.emit()
           this.videoChangeOwnership = undefined
         },
 
-        err => this.notifier.error(err.message)
-      )
+        error: err => this.notifier.error(err.message)
+      })
   }
 }