mirror of https://github.com/Chocobozzz/PeerTube
Fix avatar with username starting with numbers
parent
fbd573e59c
commit
f41efa52a4
|
@ -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>
|
||||||
|
|
|
@ -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]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue