diff options
Diffstat (limited to 'client/src/app/shared')
3 files changed, 20 insertions, 10 deletions
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 b2e1ef46e..600984aa2 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 | |||
@@ -23,7 +23,7 @@ export class ActorAvatarComponent { | |||
23 | 23 | ||
24 | @Input() previewImage: string | 24 | @Input() previewImage: string |
25 | 25 | ||
26 | @Input() size: ActorAvatarSize = '32' | 26 | @Input() size: ActorAvatarSize |
27 | 27 | ||
28 | // Use an external link | 28 | // Use an external link |
29 | @Input() href: string | 29 | @Input() href: string |
@@ -50,13 +50,13 @@ export class ActorAvatarComponent { | |||
50 | } | 50 | } |
51 | 51 | ||
52 | get defaultAvatarUrl () { | 52 | get defaultAvatarUrl () { |
53 | if (this.account) return Account.GET_DEFAULT_AVATAR_URL(+this.size) | 53 | if (this.account) return Account.GET_DEFAULT_AVATAR_URL(this.getSizeNumber()) |
54 | if (this.channel) return VideoChannel.GET_DEFAULT_AVATAR_URL(+this.size) | 54 | if (this.channel) return VideoChannel.GET_DEFAULT_AVATAR_URL(this.getSizeNumber()) |
55 | } | 55 | } |
56 | 56 | ||
57 | get avatarUrl () { | 57 | get avatarUrl () { |
58 | if (this.account) return Account.GET_ACTOR_AVATAR_URL(this.account, +this.size) | 58 | if (this.account) return Account.GET_ACTOR_AVATAR_URL(this.account, this.getSizeNumber()) |
59 | if (this.channel) return VideoChannel.GET_ACTOR_AVATAR_URL(this.channel, +this.size) | 59 | if (this.channel) return VideoChannel.GET_ACTOR_AVATAR_URL(this.channel, this.getSizeNumber()) |
60 | 60 | ||
61 | return '' | 61 | return '' |
62 | } | 62 | } |
@@ -88,6 +88,12 @@ export class ActorAvatarComponent { | |||
88 | return !!this.account || !!this.channel | 88 | return !!this.account || !!this.channel |
89 | } | 89 | } |
90 | 90 | ||
91 | private getSizeNumber () { | ||
92 | if (this.size) return +this.size | ||
93 | |||
94 | return undefined | ||
95 | } | ||
96 | |||
91 | private getColorTheme () { | 97 | private getColorTheme () { |
92 | const initialLowercase = this.initial.toLowerCase() | 98 | const initialLowercase = this.initial.toLowerCase() |
93 | 99 | ||
diff --git a/client/src/app/shared/shared-main/account/account.model.ts b/client/src/app/shared/shared-main/account/account.model.ts index a26a9c11c..e34f6ef64 100644 --- a/client/src/app/shared/shared-main/account/account.model.ts +++ b/client/src/app/shared/shared-main/account/account.model.ts | |||
@@ -17,12 +17,12 @@ export class Account extends Actor implements ServerAccount { | |||
17 | 17 | ||
18 | userId?: number | 18 | userId?: number |
19 | 19 | ||
20 | static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size: number) { | 20 | static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size?: number) { |
21 | return Actor.GET_ACTOR_AVATAR_URL(actor, size) | 21 | return Actor.GET_ACTOR_AVATAR_URL(actor, size) |
22 | } | 22 | } |
23 | 23 | ||
24 | static GET_DEFAULT_AVATAR_URL (size: number) { | 24 | static GET_DEFAULT_AVATAR_URL (size?: number) { |
25 | if (size <= 48) { | 25 | if (size && size <= 48) { |
26 | return `${window.location.origin}/client/assets/images/default-avatar-account-48x48.png` | 26 | return `${window.location.origin}/client/assets/images/default-avatar-account-48x48.png` |
27 | } | 27 | } |
28 | 28 | ||
diff --git a/client/src/app/shared/shared-main/account/actor.model.ts b/client/src/app/shared/shared-main/account/actor.model.ts index 977fdb7e5..8427c9902 100644 --- a/client/src/app/shared/shared-main/account/actor.model.ts +++ b/client/src/app/shared/shared-main/account/actor.model.ts | |||
@@ -20,8 +20,12 @@ export abstract class Actor implements ServerActor { | |||
20 | 20 | ||
21 | isLocal: boolean | 21 | isLocal: boolean |
22 | 22 | ||
23 | static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size: number) { | 23 | static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size?: number) { |
24 | const avatar = actor.avatars.sort((a, b) => a.width - b.width).find(a => a.width >= size) | 24 | const avatars = actor.avatars.sort((a, b) => a.width - b.width) |
25 | |||
26 | const avatar = size | ||
27 | ? avatars.find(a => a.width >= size) | ||
28 | : avatars[0] | ||
25 | 29 | ||
26 | if (!avatar) return '' | 30 | if (!avatar) return '' |
27 | if (avatar.url) return avatar.url | 31 | if (avatar.url) return avatar.url |