]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
Add new plugin/peertube version notifs
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-settings.component.ts
index 7ea4610d47bba6a40992bcd79070ec95082821ee..c1636895204e6278f777c2d53339b37f3d86122d 100644 (file)
@@ -1,6 +1,8 @@
 import { ViewportScroller } from '@angular/common'
+import { HttpErrorResponse } from '@angular/common/http'
 import { AfterViewChecked, Component, OnInit } from '@angular/core'
 import { AuthService, Notifier, User, UserService } from '@app/core'
+import { uploadErrorHandler } from '@app/helpers'
 
 @Component({
   selector: 'my-account-settings',
@@ -44,7 +46,24 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
           this.user.updateAccountAvatar(data.avatar)
         },
 
-        err => this.notifier.error(err.message)
+        (err: HttpErrorResponse) => uploadErrorHandler({
+          err,
+          name: $localize`avatar`,
+          notifier: this.notifier
+        })
+      )
+  }
+
+  onAvatarDelete () {
+    this.userService.deleteAvatar()
+      .subscribe(
+        data => {
+          this.notifier.success($localize`Avatar deleted.`)
+
+          this.user.updateAccountAvatar()
+        },
+
+        (err: HttpErrorResponse) => this.notifier.error(err.message)
       )
   }
 }