]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
Fix redundancy federation in some cases
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-thumbnail / video-thumbnail.component.ts
CommitLineData
b7819090 1import { Component, EventEmitter, Input, Output } from '@angular/core'
67ed6552 2import { ScreenService } from '@app/core'
5c0904fc 3import { VideoState } from '@shared/models'
67ed6552 4import { Video } from '../shared-main'
202f6b6c
C
5
6@Component({
7 selector: 'my-video-thumbnail',
8 styleUrls: [ './video-thumbnail.component.scss' ],
9 templateUrl: './video-thumbnail.component.html'
10})
11export class VideoThumbnailComponent {
12 @Input() video: Video
13 @Input() nsfw = false
0bdad52f
C
14
15 @Input() videoRouterLink: any[]
be27ef3b 16 @Input() queryParams: { [ p: string ]: any }
0bdad52f
C
17 @Input() videoHref: string
18 @Input() videoTarget: string
3290f37c 19
b7819090
C
20 @Input() displayWatchLaterPlaylist: boolean
21 @Input() inWatchLaterPlaylist: boolean
29128b2f 22
b7819090
C
23 @Output() watchLaterClick = new EventEmitter<boolean>()
24
25 addToWatchLaterText: string
26 addedToWatchLaterText: string
29128b2f 27
66357162
C
28 constructor (private screenService: ScreenService) {
29 this.addToWatchLaterText = $localize`Add to watch later`
30 this.addedToWatchLaterText = $localize`Remove from watch later`
e2f01c47 31 }
bbe0f064 32
5c0904fc
C
33 isLiveEnded () {
34 return this.video.state.id === VideoState.LIVE_ENDED
35 }
36
3290f37c
C
37 getImageUrl () {
38 if (!this.video) return ''
39
bbe0f064 40 if (this.screenService.isInMobileView()) {
3290f37c
C
41 return this.video.previewUrl
42 }
43
44 return this.video.thumbnailUrl
45 }
6e46de09
C
46
47 getProgressPercent () {
48 if (!this.video.userHistory) return 0
49
50 const currentTime = this.video.userHistory.currentTime
51
52 return (currentTime / this.video.duration) * 100
53 }
e2f01c47
C
54
55 getVideoRouterLink () {
0bdad52f 56 if (this.videoRouterLink) return this.videoRouterLink
e2f01c47
C
57
58 return [ '/videos/watch', this.video.uuid ]
59 }
29128b2f 60
b7819090
C
61 onWatchLaterClick (event: Event) {
62 this.watchLaterClick.emit(this.inWatchLaterPlaylist)
29128b2f 63
b7819090
C
64 event.stopPropagation()
65 return false
29128b2f 66 }
202f6b6c 67}