]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/video/video.model.ts
Add banner migrations
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / video / video.model.ts
index 92f5bc0c07c3b2696a95ad8d544f5ab5fd6227b5..1c2c4a575199b7d358212c9f7312d9165ec7db73 100644 (file)
@@ -1,9 +1,12 @@
 import { AuthUser } from '@app/core'
 import { User } from '@app/core/users/user.model'
 import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
+import { Account } from '@app/shared/shared-main/account/account.model'
+import { Actor } from '@app/shared/shared-main/account/actor.model'
+import { VideoChannel } from '@app/shared/shared-main/video-channel/video-channel.model'
 import { peertubeTranslate } from '@shared/core-utils/i18n'
 import {
-  Avatar,
+  ActorImage,
   ServerConfig,
   UserRight,
   Video as VideoServerModel,
@@ -12,7 +15,6 @@ import {
   VideoScheduleUpdate,
   VideoState
 } from '@shared/models'
-import { Actor } from '../account/actor.model'
 
 export class Video implements VideoServerModel {
   byVideoChannel: string
@@ -70,7 +72,7 @@ export class Video implements VideoServerModel {
     displayName: string
     url: string
     host: string
-    avatar?: Avatar
+    avatar?: ActorImage
   }
 
   channel: {
@@ -79,7 +81,7 @@ export class Video implements VideoServerModel {
     displayName: string
     url: string
     host: string
-    avatar?: Avatar
+    avatar?: ActorImage
   }
 
   userHistory?: {
@@ -142,8 +144,8 @@ export class Video implements VideoServerModel {
 
     this.byAccount = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)
     this.byVideoChannel = Actor.CREATE_BY_STRING(hash.channel.name, hash.channel.host)
-    this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
-    this.videoChannelAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.channel)
+    this.accountAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.account)
+    this.videoChannelAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.channel)
 
     this.category.label = peertubeTranslate(this.category.label, translations)
     this.licence.label = peertubeTranslate(this.licence.label, translations)
@@ -201,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`
+  }
 }