-
- ratingMethods[nextRating].call(this.videoService, this.video.id)
- .subscribe(
- () => {
- // Update the video like attribute
- this.updateVideoRating(this.userRating, nextRating)
- this.userRating = nextRating
- },
-
- (err: { message: string }) => this.notifier.error(err.message)
- )
- }
-
- private updateVideoRating (oldRating: UserVideoRateType, newRating: UserVideoRateType) {
- let likesToIncrement = 0
- let dislikesToIncrement = 0
-
- if (oldRating) {
- if (oldRating === 'like') likesToIncrement--
- if (oldRating === 'dislike') dislikesToIncrement--
- }
-
- if (newRating === 'like') likesToIncrement++
- if (newRating === 'dislike') dislikesToIncrement++
-
- this.video.likes += likesToIncrement
- this.video.dislikes += dislikesToIncrement
-
- this.video.buildLikeAndDislikePercents()
- this.setVideoLikesBarTooltipText()
- }
-
- private setOpenGraphTags () {
- this.metaService.setTitle(this.video.name)
-
- this.metaService.setTag('og:type', 'video')
-
- this.metaService.setTag('og:title', this.video.name)
- this.metaService.setTag('name', this.video.name)
-
- this.metaService.setTag('og:description', this.video.description)
- this.metaService.setTag('description', this.video.description)
-
- this.metaService.setTag('og:image', this.video.previewPath)
-
- this.metaService.setTag('og:duration', this.video.duration.toString())
-
- this.metaService.setTag('og:site_name', 'PeerTube')
-
- this.metaService.setTag('og:url', window.location.href)
- this.metaService.setTag('url', window.location.href)