Refactor last PR

This commit is contained in:
Chocobozzz 2020-11-27 15:57:38 +01:00
parent 413b9729ee
commit 4ec25ae825
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 13 additions and 19 deletions

View File

@ -54,9 +54,7 @@
<div class="video-info-date-views">
<ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container>
<span i18n
title="{{ getExactNumberOfViews() }}"
class="views">
<span i18n [title]="video.getExactNumberOfViews()" class="views">
• {{ video.views | myNumberFormatter }}
<ng-container *ngIf="!video.isLive">views</ng-container>
<ng-container *ngIf="video.isLive">viewers</ng-container>
@ -73,9 +71,7 @@
<div class="d-none d-md-block video-info-date-views">
<ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container>
<span i18n
title="{{ getExactNumberOfViews() }}"
class="views">
<span i18n [title]="video.getExactNumberOfViews()" class="views">
• {{ video.views | myNumberFormatter }}
<ng-container *ngIf="!video.isLive">views</ng-container>
<ng-container *ngIf="video.isLive">viewers</ng-container>

View File

@ -219,12 +219,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
return $localize`You need to be <a href="/login">logged in</a> to rate this video.`
}
getExactNumberOfViews () {
return (this.video.views >= 1000)
? `${this.video.views} ${this.video.isLive ? $localize`viewers` : $localize`views`}`
: ''
}
showMoreDescription () {
if (this.completeVideoDescription === undefined) {
return this.loadCompleteDescription()

View File

@ -203,4 +203,14 @@ export class Video implements VideoServerModel {
canBeDuplicatedBy (user: AuthUser) {
return user && this.isLocal === false && user.hasRight(UserRight.MANAGE_VIDEOS_REDUNDANCIES)
}
getExactNumberOfViews () {
if (this.views < 1000) return ''
if (this.isLive) {
return $localize`${this.views} viewers`
}
return $localize`${this.views} views`
}
}

View File

@ -26,7 +26,7 @@
<span class="video-miniature-created-at-views">
<my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle>
<span class="views" title="{{ getExactNumberOfViews() }}">
<span class="views" [title]="video.getExactNumberOfViews()">
<ng-container *ngIf="displayOptions.date && displayOptions.views"></ng-container>
<ng-container i18n *ngIf="displayOptions.views">
{video.views, plural, =1 {1 view} other {{{ video.views | myNumberFormatter }} views}}

View File

@ -190,12 +190,6 @@ export class VideoMiniatureComponent implements OnInit {
return this.video.videoChannelAvatarUrl
}
getExactNumberOfViews () {
return (this.video.views >= 1000 && this.displayOptions.views)
? `${this.video.views} ${this.video.isLive ? $localize`viewers` : $localize`views`}`
: ''
}
loadActions () {
if (this.displayVideoActions) this.showActions = true