]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/video-channel/video-channel.model.ts
2f4597343bb291a1c61d6b2740e64371c2038e51
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video-channel / video-channel.model.ts
1 import { VideoChannel as ServerVideoChannel, ViewsPerDate } from '../../../../../shared/models/videos'
2 import { Actor } from '../actor/actor.model'
3 import { Account } from '../../../../../shared/models/actors'
4
5 export class VideoChannel extends Actor implements ServerVideoChannel {
6 displayName: string
7 description: string
8 support: string
9 isLocal: boolean
10 nameWithHost: string
11 nameWithHostForced: string
12
13 ownerAccount?: Account
14 ownerBy?: string
15 ownerAvatarUrl?: string
16
17 videosCount?: number
18
19 viewsPerDay?: ViewsPerDate[]
20
21 constructor (hash: ServerVideoChannel) {
22 super(hash)
23
24 this.displayName = hash.displayName
25 this.description = hash.description
26 this.support = hash.support
27 this.isLocal = hash.isLocal
28 this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
29 this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
30
31 this.videosCount = hash.videosCount
32
33 if (hash.viewsPerDay) {
34 this.viewsPerDay = hash.viewsPerDay.map(v => ({ ...v, date: new Date(v.date) }))
35 }
36
37 if (hash.ownerAccount) {
38 this.ownerAccount = hash.ownerAccount
39 this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
40 this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount)
41 }
42 }
43 }