RHeactorJS/web-app

View on GitHub
js/controller/account-avatar.js

Summary

Maintainability
A
0 mins
Test Coverage
import {URIValue} from '@rheactorjs/value-objects'

export class AccountAvatarController {
  constructor (ClientStorageService, UserService) {
    this.uploadSuccess = avatarUrl => {
      return ClientStorageService.getValidToken()
        .then(token => UserService.updateProperty(this.user, 'avatar', avatarUrl.toString(), token))
        .then(u => {
          ClientStorageService.set('me', u)
          this.user = u
        })
    }
    ClientStorageService.getValidToken()
      .then(token => UserService.get(new URIValue(token.sub), token))
      .then(user => {
        this.user = user
      })
  }
}