Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix avatar with username starting with numbers

Chocobozzzf41efa52a412
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 13a5385a82..c285b6cc38 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 @@
<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>
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 bc7e8a0963..b2e1ef46ea 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 {
}
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]
}