From 20b40b195aa89778a8b6dc22f76a2ea76ef406a8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Feb 2018 09:49:40 +0100 Subject: Handle user rates in real time --- client/src/app/shared/video/video-details.model.ts | 8 ++++++-- client/src/app/videos/+video-watch/video-watch.component.ts | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts index a22ed68da..1882a8165 100644 --- a/client/src/app/shared/video/video-details.model.ts +++ b/client/src/app/shared/video/video-details.model.ts @@ -60,8 +60,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { this.support = hash.support this.commentsEnabled = hash.commentsEnabled - this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100 - this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100 + this.buildLikeAndDislikePercents() } getAppropriateMagnetUri (actualDownloadSpeed = 0) { @@ -90,4 +89,9 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { isUpdatableBy (user: AuthUser) { return user && this.isLocal === true && (this.accountName === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO)) } + + buildLikeAndDislikePercents () { + this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100 + this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100 + } } diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index c9bfa7ffb..3965bade8 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -411,6 +411,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.video.likes += likesToIncrement this.video.dislikes += dislikesToIncrement + this.video.buildLikeAndDislikePercents() + + this.setVideoLikesBarTooltipText() } private updateOtherVideosDisplayed () { -- cgit v1.2.3