diff options
author | kimsible <kimsible@users.noreply.github.com> | 2020-11-18 19:20:05 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-25 11:12:06 +0100 |
commit | c418d483004dfbae9ea38d54aa1577db46d34a8a (patch) | |
tree | c4fd4ec790c6e5d6bc44e887090a8286e10fffd2 /client/src/app/shared/shared-main/video-channel | |
parent | 18490b07650d77d7fe376970b749af5a8c672fd6 (diff) | |
download | PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.tar.gz PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.tar.zst PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.zip |
Add new default different avatar for channel and account
Diffstat (limited to 'client/src/app/shared/shared-main/video-channel')
-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 | } |