]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-library/+my-video-channels/my-video-channel-update.component.ts
Redesign account's channels page
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-library / +my-video-channels / my-video-channel-update.component.ts
index c6cb5ade651b4273d8110491514171dd228a53ce..6cd1ff503c0d287db4cbb84ad534fe8a56ac1c84 100644 (file)
@@ -11,6 +11,8 @@ import { FormValidatorService } from '@app/shared/shared-forms'
 import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
 import { ServerConfig, VideoChannelUpdate } from '@shared/models'
 import { MyVideoChannelEdit } from './my-video-channel-edit'
+import { HttpErrorResponse } from '@angular/common/http'
+import { uploadErrorHandler } from '@app/helpers'
 
 @Component({
   selector: 'my-video-channel-update',
@@ -107,10 +109,27 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements
             this.videoChannelToUpdate.updateAvatar(data.avatar)
           },
 
-          err => this.notifier.error(err.message)
+          (err: HttpErrorResponse) => uploadErrorHandler({
+            err,
+            name: $localize`avatar`,
+            notifier: this.notifier
+          })
         )
   }
 
+  onAvatarDelete () {
+    this.videoChannelService.deleteVideoChannelAvatar(this.videoChannelToUpdate.name)
+                            .subscribe(
+                              data => {
+                                this.notifier.success($localize`Avatar deleted.`)
+
+                                this.videoChannelToUpdate.resetAvatar()
+                              },
+
+                              err => this.notifier.error(err.message)
+                            )
+  }
+
   get maxAvatarSize () {
     return this.serverConfig.avatar.file.size.max
   }