]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/+video-watch/comment/video-comment.model.ts
Fix scroll menu on touch devices
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.model.ts
1 import { Account as AccountInterface } from '../../../../../../shared/models/actors'
2 import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model'
3 import { Actor } from '@app/shared/actor/actor.model'
4 import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'
5
6 export class VideoComment implements VideoCommentServerModel {
7 id: number
8 url: string
9 text: string
10 threadId: number
11 inReplyToCommentId: number
12 videoId: number
13 createdAt: Date | string
14 updatedAt: Date | string
15 deletedAt: Date | string
16 isDeleted: boolean
17 account: AccountInterface
18 totalRepliesFromVideoAuthor: number
19 totalReplies: number
20 by: string
21 accountAvatarUrl: string
22
23 isLocal: boolean
24
25 constructor (hash: VideoCommentServerModel) {
26 this.id = hash.id
27 this.url = hash.url
28 this.text = hash.text
29 this.threadId = hash.threadId
30 this.inReplyToCommentId = hash.inReplyToCommentId
31 this.videoId = hash.videoId
32 this.createdAt = new Date(hash.createdAt.toString())
33 this.updatedAt = new Date(hash.updatedAt.toString())
34 this.deletedAt = hash.deletedAt ? new Date(hash.deletedAt.toString()) : null
35 this.isDeleted = hash.isDeleted
36 this.account = hash.account
37 this.totalRepliesFromVideoAuthor = hash.totalRepliesFromVideoAuthor
38 this.totalReplies = hash.totalReplies
39
40 if (this.account) {
41 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
42 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
43
44 const absoluteAPIUrl = getAbsoluteAPIUrl()
45 const thisHost = new URL(absoluteAPIUrl).host
46 this.isLocal = this.account.host.trim() === thisHost
47 }
48 }
49 }