]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/users/user.model.ts
Fix forgot password message regarding email
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user.model.ts
index b4be2270f8c82818db140ed7a3731d9f752f2388..581ea785964d2dee22ac251d5f2571f0adb7ca91 100644 (file)
@@ -9,6 +9,7 @@ import {
 import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
 import { Actor } from '@app/shared/actor/actor.model'
 import { Account } from '@app/shared/account/account.model'
+import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
 
 export type UserConstructorHash = {
   id: number,
@@ -33,7 +34,6 @@ export class User implements UserServerModel {
   account: Account
   videoChannels: VideoChannel[]
   createdAt: Date
-  accountAvatarUrl: string
 
   constructor (hash: UserConstructorHash) {
     this.id = hash.id
@@ -64,8 +64,12 @@ export class User implements UserServerModel {
     if (hash.createdAt !== undefined) {
       this.createdAt = hash.createdAt
     }
+  }
+
+  get accountAvatarUrl () {
+    if (!this.account) return ''
 
-    this.updateComputedAttributes()
+    return this.account.avatarUrl
   }
 
   hasRight (right: UserRight) {
@@ -80,11 +84,9 @@ export class User implements UserServerModel {
     if (obj.account !== undefined) {
       this.account = new Account(obj.account)
     }
-
-    this.updateComputedAttributes()
   }
 
-  private updateComputedAttributes () {
-    this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
+  updateAccountAvatar (newAccountAvatar: Avatar) {
+    this.account.updateAvatar(newAccountAvatar)
   }
 }