diff options
Diffstat (limited to 'client/src/app/shared/shared-main/video-channel/video-channel.model.ts')
-rw-r--r-- | client/src/app/shared/shared-main/video-channel/video-channel.model.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts index 123389afb..4f1f5b65d 100644 --- a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts +++ b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { VideoChannel as ServerVideoChannel, ViewsPerDate, Account } from '@shared/models' | 1 | import { VideoChannel as ServerVideoChannel, ViewsPerDate, Account, Avatar } from '@shared/models' |
2 | import { Actor } from '../account/actor.model' | 2 | import { Actor } from '../account/actor.model' |
3 | 3 | ||
4 | export class VideoChannel extends Actor implements ServerVideoChannel { | 4 | export class VideoChannel extends Actor implements ServerVideoChannel { |
@@ -17,9 +17,19 @@ export class VideoChannel extends Actor implements ServerVideoChannel { | |||
17 | 17 | ||
18 | viewsPerDay?: ViewsPerDate[] | 18 | viewsPerDay?: ViewsPerDate[] |
19 | 19 | ||
20 | static GET_ACTOR_AVATAR_URL (actor: object) { | ||
21 | return Actor.GET_ACTOR_AVATAR_URL(actor) || this.GET_DEFAULT_AVATAR_URL() | ||
22 | } | ||
23 | |||
24 | static GET_DEFAULT_AVATAR_URL () { | ||
25 | return `${window.location.origin}/client/assets/images/default-avatar-videochannel.png` | ||
26 | } | ||
27 | |||
20 | constructor (hash: ServerVideoChannel) { | 28 | constructor (hash: ServerVideoChannel) { |
21 | super(hash) | 29 | super(hash) |
22 | 30 | ||
31 | this.updateComputedAttributes() | ||
32 | |||
23 | this.displayName = hash.displayName | 33 | this.displayName = hash.displayName |
24 | this.description = hash.description | 34 | this.description = hash.description |
25 | this.support = hash.support | 35 | this.support = hash.support |
@@ -39,4 +49,14 @@ export class VideoChannel extends Actor implements ServerVideoChannel { | |||
39 | this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount) | 49 | this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount) |
40 | } | 50 | } |
41 | } | 51 | } |
52 | |||
53 | updateAvatar (newAvatar: Avatar) { | ||
54 | this.avatar = newAvatar | ||
55 | |||
56 | this.updateComputedAttributes() | ||
57 | } | ||
58 | |||
59 | private updateComputedAttributes () { | ||
60 | this.avatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this) | ||
61 | } | ||
42 | } | 62 | } |