X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Factor%2Factor.model.ts;h=adecec1fce53405ac73d23d6952fe2242995afb0;hb=88108880bbdba473cfe36ecbebc1c3c4f972e102;hp=f820dc3c48e4f62fd614b4ff22eebc288e3b9fb4;hpb=db400f447a9f7aae1c56fa25396e93069744483f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.ts index f820dc3c4..adecec1fc 100644 --- a/client/src/app/shared/actor/actor.model.ts +++ b/client/src/app/shared/actor/actor.model.ts @@ -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) } }