]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
Merge pull request #1105 from BO41/unused-imports
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-settings.component.ts
index 15f977e586477aa74303c185c64a8efb186df324..62053d97b2003220cf0f7da19c3bfc3858c66001 100644 (file)
@@ -2,7 +2,6 @@ import { Component, OnInit, ViewChild } from '@angular/core'
 import { NotificationsService } from 'angular2-notifications'
 import { BytesPipe } from 'ngx-pipes'
 import { AuthService } from '../../core'
-import { ServerService } from '../../core/server'
 import { User } from '../../shared'
 import { UserService } from '../../shared/users'
 import { I18n } from '@ngx-translate/i18n-polyfill'
@@ -13,8 +12,6 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
   styleUrls: [ './my-account-settings.component.scss' ]
 })
 export class MyAccountSettingsComponent implements OnInit {
-  @ViewChild('avatarfileInput') avatarfileInput
-
   user: User = null
   userVideoQuota = '0'
   userVideoQuotaUsed = 0
@@ -22,7 +19,6 @@ export class MyAccountSettingsComponent implements OnInit {
   constructor (
     private userService: UserService,
     private authService: AuthService,
-    private serverService: ServerService,
     private notificationsService: NotificationsService,
     private i18n: I18n
   ) {}
@@ -48,29 +44,16 @@ export class MyAccountSettingsComponent implements OnInit {
       .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed)
   }
 
-  changeAvatar () {
-    const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ]
-
-    const formData = new FormData()
-    formData.append('avatarfile', avatarfile)
-
+  onAvatarChange (formData: FormData) {
     this.userService.changeAvatar(formData)
       .subscribe(
         data => {
           this.notificationsService.success(this.i18n('Success'), this.i18n('Avatar changed.'))
 
-          this.user.account.avatar = data.avatar
+          this.user.updateAccountAvatar(data.avatar)
         },
 
         err => this.notificationsService.error(this.i18n('Error'), err.message)
       )
   }
-
-  get maxAvatarSize () {
-    return this.serverService.getConfig().avatar.file.size.max
-  }
-
-  get avatarExtensions () {
-    return this.serverService.getConfig().avatar.file.extensions.join(',')
-  }
 }