]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/actor/actor.model.ts
Merge branch 'develop' into pr/1217
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / actor / actor.model.ts
index f820dc3c48e4f62fd614b4ff22eebc288e3b9fb4..adecec1fce53405ac73d23d6952fe2242995afb0 100644 (file)
@@ -16,7 +16,7 @@ export abstract class Actor implements ActorServer {
 
   avatarUrl: string
 
-  static GET_ACTOR_AVATAR_URL (actor: { avatar: Avatar }) {
+  static GET_ACTOR_AVATAR_URL (actor: { avatar?: { path: string } }) {
     const absoluteAPIUrl = getAbsoluteAPIUrl()
 
     if (actor && actor.avatar) return absoluteAPIUrl + actor.avatar.path
@@ -45,6 +45,16 @@ export abstract class Actor implements ActorServer {
     this.updatedAt = new Date(hash.updatedAt.toString())
     this.avatar = hash.avatar
 
+    this.updateComputedAttributes()
+  }
+
+  updateAvatar (newAvatar: Avatar) {
+    this.avatar = newAvatar
+
+    this.updateComputedAttributes()
+  }
+
+  private updateComputedAttributes () {
     this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
   }
 }