aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-02-28 16:44:11 +0100
committerChocobozzz <me@florianbigard.com>2022-02-28 16:44:11 +0100
commitf41efa52a412272928ba90e06c9a9a9c471d1ca3 (patch)
tree013750584908d5da554712f50124720d21f750e3 /client/src/app/shared
parentfbd573e59cb8d96edb79663a2cd3696be00b23ad (diff)
downloadPeerTube-f41efa52a412272928ba90e06c9a9a9c471d1ca3.tar.gz
PeerTube-f41efa52a412272928ba90e06c9a9a9c471d1ca3.tar.zst
PeerTube-f41efa52a412272928ba90e06c9a9a9c471d1ca3.zip
Fix avatar with username starting with numbers
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-actor-image/actor-avatar.component.html2
-rw-r--r--client/src/app/shared/shared-actor-image/actor-avatar.component.ts6
2 files changed, 5 insertions, 3 deletions
diff --git a/client/src/app/shared/shared-actor-image/actor-avatar.component.html b/client/src/app/shared/shared-actor-image/actor-avatar.component.html
index 13a5385a8..c285b6cc3 100644
--- a/client/src/app/shared/shared-actor-image/actor-avatar.component.html
+++ b/client/src/app/shared/shared-actor-image/actor-avatar.component.html
@@ -1,7 +1,7 @@
1<ng-template #img> 1<ng-template #img>
2 <img *ngIf="previewImage || avatarUrl || !initial" [class]="getClass('avatar')" [src]="previewImage || avatarUrl || defaultAvatarUrl" [alt]="alt" /> 2 <img *ngIf="previewImage || avatarUrl || !initial" [class]="getClass('avatar')" [src]="previewImage || avatarUrl || defaultAvatarUrl" [alt]="alt" />
3 3
4 <div *ngIf="!avatarUrl && initial" [class]="getClass('initial')"> 4 <div *ngIf="!avatarUrl && initial" [ngClass]="getClass('initial')">
5 <span>{{ initial }}</span> 5 <span>{{ initial }}</span>
6 </div> 6 </div>
7</ng-template> 7</ng-template>
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 bc7e8a096..b2e1ef46e 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
@@ -89,9 +89,11 @@ export class ActorAvatarComponent {
89 } 89 }
90 90
91 private getColorTheme () { 91 private getColorTheme () {
92 const initialLowercase = this.initial.toLowerCase()
93
92 // Keep consistency with CSS 94 // Keep consistency with CSS
93 const themes = { 95 const themes = {
94 abc: 'blue', 96 '0123456789abc': 'blue',
95 def: 'green', 97 def: 'green',
96 ghi: 'purple', 98 ghi: 'purple',
97 jkl: 'gray', 99 jkl: 'gray',
@@ -102,7 +104,7 @@ export class ActorAvatarComponent {
102 } 104 }
103 105
104 const theme = Object.keys(themes) 106 const theme = Object.keys(themes)
105 .find(chars => chars.includes(this.initial)) 107 .find(chars => chars.includes(initialLowercase))
106 108
107 return themes[theme] 109 return themes[theme]
108 } 110 }