1
0
Fork 0

Fix avatar with username starting with numbers

This commit is contained in:
Chocobozzz 2022-02-28 16:44:11 +01:00
parent fbd573e59c
commit f41efa52a4
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 5 additions and 3 deletions

View file

@ -1,7 +1,7 @@
<ng-template #img>
<img *ngIf="previewImage || avatarUrl || !initial" [class]="getClass('avatar')" [src]="previewImage || avatarUrl || defaultAvatarUrl" [alt]="alt" />
<div *ngIf="!avatarUrl && initial" [class]="getClass('initial')">
<div *ngIf="!avatarUrl && initial" [ngClass]="getClass('initial')">
<span>{{ initial }}</span>
</div>
</ng-template>

View file

@ -89,9 +89,11 @@ export class ActorAvatarComponent {
}
private getColorTheme () {
const initialLowercase = this.initial.toLowerCase()
// Keep consistency with CSS
const themes = {
abc: 'blue',
'0123456789abc': 'blue',
def: 'green',
ghi: 'purple',
jkl: 'gray',
@ -102,7 +104,7 @@ export class ActorAvatarComponent {
}
const theme = Object.keys(themes)
.find(chars => chars.includes(this.initial))
.find(chars => chars.includes(initialLowercase))
return themes[theme]
}