Parse like and dislike count to add comma separator (#1796)

* Parse like and dislike count to add comma separator

* Use user locale with fallback for like count
This commit is contained in:
vallode 2021-10-06 22:09:08 +01:00 committed by GitHub
parent 7a3aa8ff20
commit dc26141338
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -198,6 +198,24 @@ export default Vue.extend({
return this.likeCount + this.dislikeCount
},
parsedLikeCount: function () {
if (this.hideVideoLikesAndDislikes) {
return null
}
const locale = this.currentLocale.replace('_', '-')
return this.likeCount.toLocaleString([locale, 'en'])
},
parsedDislikeCount: function () {
if (this.hideVideoLikesAndDislikes) {
return null
}
const locale = this.currentLocale.replace('_', '-')
return this.dislikeCount.toLocaleString([locale, 'en'])
},
likePercentageRatio: function () {
return parseInt(this.likeCount / this.totalLikeCount * 100)
},

View File

@ -56,8 +56,8 @@
:style="{ background: `linear-gradient(to right, var(--accent-color) ${likePercentageRatio}%, #9E9E9E ${likePercentageRatio}%` }"
/>
<div>
<span class="likeCount"><font-awesome-icon icon="thumbs-up" /> {{ likeCount }}</span>
<span class="dislikeCount"><font-awesome-icon icon="thumbs-down" /> {{ dislikeCount }}</span>
<span class="likeCount"><font-awesome-icon icon="thumbs-up" /> {{ parsedLikeCount }}</span>
<span class="dislikeCount"><font-awesome-icon icon="thumbs-down" /> {{ parsedDislikeCount }}</span>
</div>
</div>
</div>