X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-actor-image%2Factor-avatar.component.ts;h=fa4f1e51f99678d04e2f3650119d93854fa8073c;hb=5b0ec7cddb1ae6dbd2057f067382866f846b882c;hp=600984aa2d6baaa402d89af2bb292179daf7e209;hpb=b13a0a48bacb53e65e665774e621326452045294;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts index 600984aa2..fa4f1e51f 100644 --- a/client/src/app/shared/shared-actor-image/actor-avatar.component.ts +++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core' +import { Component, Input, OnChanges } from '@angular/core' import { VideoChannel } from '../shared-main' import { Account } from '../shared-main/account/account.model' @@ -15,7 +15,7 @@ export type ActorAvatarSize = '18' | '25' | '28' | '32' | '34' | '35' | '36' | ' styleUrls: [ './actor-avatar.component.scss' ], templateUrl: './actor-avatar.component.html' }) -export class ActorAvatarComponent { +export class ActorAvatarComponent implements OnChanges { private _title: string @Input() account: ActorInput @@ -42,6 +42,8 @@ export class ActorAvatarComponent { return '' } + classes: string[] = [] + get alt () { if (this.account) return $localize`Account avatar` if (this.channel) return $localize`Channel avatar` @@ -68,20 +70,18 @@ export class ActorAvatarComponent { return name.slice(0, 1) } - getClass (type: 'avatar' | 'initial') { - const base = [ 'avatar' ] + ngOnChanges () { + this.classes = [ 'avatar' ] - if (this.size) base.push(`avatar-${this.size}`) + if (this.size) this.classes.push(`avatar-${this.size}`) - if (this.channel) base.push('channel') - else base.push('account') + if (this.channel) this.classes.push('channel') + else this.classes.push('account') - if (type === 'initial' && this.initial) { - base.push('initial') - base.push(this.getColorTheme()) + if (!this.avatarUrl && this.initial) { + this.classes.push('initial') + this.classes.push(this.getColorTheme()) } - - return base } hasActor () {