Fix avatar with username starting with numbers

pull/4826/head
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> <ng-template #img>
<img *ngIf="previewImage || avatarUrl || !initial" [class]="getClass('avatar')" [src]="previewImage || avatarUrl || defaultAvatarUrl" [alt]="alt" /> <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> <span>{{ initial }}</span>
</div> </div>
</ng-template> </ng-template>

View File

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