X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fvideo-thumbnail.component.ts;h=fe65ade9442a1b5da0beedaab65b269fa699d0fd;hb=e2409062dedf8856c56ef1bdc98ca623e21c4f3b;hp=e543e9903bbf1855bc7e5d820b07f1f699634c30;hpb=202f6b6c9dcc9b0aec4b0c1b15e455c22a7952a7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/video/video-thumbnail.component.ts b/client/src/app/shared/video/video-thumbnail.component.ts index e543e9903..fe65ade94 100644 --- a/client/src/app/shared/video/video-thumbnail.component.ts +++ b/client/src/app/shared/video/video-thumbnail.component.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core' import { Video } from './video.model' +import { ScreenService } from '@app/shared/misc/screen.service' @Component({ selector: 'my-video-thumbnail', @@ -9,4 +10,33 @@ import { Video } from './video.model' export class VideoThumbnailComponent { @Input() video: Video @Input() nsfw = false + @Input() routerLink: any[] + @Input() queryParams: any[] + + constructor (private screenService: ScreenService) { + } + + getImageUrl () { + if (!this.video) return '' + + if (this.screenService.isInMobileView()) { + return this.video.previewUrl + } + + return this.video.thumbnailUrl + } + + getProgressPercent () { + if (!this.video.userHistory) return 0 + + const currentTime = this.video.userHistory.currentTime + + return (currentTime / this.video.duration) * 100 + } + + getVideoRouterLink () { + if (this.routerLink) return this.routerLink + + return [ '/videos/watch', this.video.uuid ] + } }