]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-actor-image/actor-avatar.component.ts
Fix forgot password button role
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-actor-image / actor-avatar.component.ts
index 835e151100897107be3bddc84dcc331e5bdc9a12..c323dc7241e020d9164eeda2b9268faafc421853 100644 (file)
@@ -1,5 +1,4 @@
 import { Component, Input } from '@angular/core'
-import { SafeResourceUrl } from '@angular/platform-browser'
 import { VideoChannel } from '../shared-main'
 import { Account } from '../shared-main/account/account.model'
 
@@ -9,18 +8,22 @@ type ActorInput = {
   url: string
 }
 
+export type ActorAvatarSize = '18' | '25' | '32' | '34' | '36' | '40' | '100' | '120'
+
 @Component({
   selector: 'my-actor-avatar',
   styleUrls: [ './actor-avatar.component.scss' ],
   templateUrl: './actor-avatar.component.html'
 })
 export class ActorAvatarComponent {
+  private _title: string
+
   @Input() account: ActorInput
   @Input() channel: ActorInput
 
-  @Input() previewImage: SafeResourceUrl
+  @Input() previewImage: string
 
-  @Input() size: '18' | '25' | '32' | '34' | '36' | '40' | '100' | '120'
+  @Input() size: ActorAvatarSize
 
   // Use an external link
   @Input() href: string
@@ -31,8 +34,6 @@ export class ActorAvatarComponent {
     this._title = value
   }
 
-  private _title: string
-
   get title () {
     if (this._title) return this._title
     if (this.account) return $localize`${this.account.name} (account page)`
@@ -48,27 +49,10 @@ export class ActorAvatarComponent {
     return ''
   }
 
-  getClass (type: 'avatar' | 'initial') {
-    const base = [ 'avatar' ]
-
-    if (this.size) base.push(`avatar-${this.size}`)
-
-    if (this.account) base.push('account')
-    else base.push('channel')
-
-    if (type === 'initial' && this.initial) {
-      base.push('initial')
-      base.push(this.getColorTheme())
-    }
-
-    return base
-  }
-
   get defaultAvatarUrl () {
-    if (this.account) Account.GET_DEFAULT_AVATAR_URL()
     if (this.channel) return VideoChannel.GET_DEFAULT_AVATAR_URL()
 
-    return ''
+    return Account.GET_DEFAULT_AVATAR_URL()
   }
 
   get avatarUrl () {
@@ -85,6 +69,22 @@ export class ActorAvatarComponent {
     return name.slice(0, 1)
   }
 
+  getClass (type: 'avatar' | 'initial') {
+    const base = [ 'avatar' ]
+
+    if (this.size) base.push(`avatar-${this.size}`)
+
+    if (this.channel) base.push('channel')
+    else base.push('account')
+
+    if (type === 'initial' && this.initial) {
+      base.push('initial')
+      base.push(this.getColorTheme())
+    }
+
+    return base
+  }
+
   hasActor () {
     return !!this.account || !!this.channel
   }