]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-video-playlist/video-playlist.model.ts
Move to sass module
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-playlist / video-playlist.model.ts
index 8f63d2abd283381b1e8041cf94ee1dc8d986e0c3..d67f372f41e7b101bd1dfb6f656770e98c159cfa 100644 (file)
@@ -1,8 +1,8 @@
-import { getAbsoluteAPIUrl } from '@app/helpers'
+import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
 import { Actor } from '@app/shared/shared-main'
+import { peertubeTranslate } from '@shared/core-utils/i18n'
 import {
   AccountSummary,
-  peertubeTranslate,
   VideoChannelSummary,
   VideoConstant,
   VideoPlaylist as ServerVideoPlaylist,
@@ -15,12 +15,12 @@ export class VideoPlaylist implements ServerVideoPlaylist {
   uuid: string
   isLocal: boolean
 
+  url: string
+
   displayName: string
   description: string
   privacy: VideoConstant<VideoPlaylistPrivacy>
 
-  thumbnailPath: string
-
   videosLength: number
 
   type: VideoConstant<VideoPlaylistType>
@@ -31,22 +31,22 @@ export class VideoPlaylist implements ServerVideoPlaylist {
   ownerAccount: AccountSummary
   videoChannel?: VideoChannelSummary
 
+  thumbnailPath: string
   thumbnailUrl: string
 
+  embedPath: string
+  embedUrl: string
+
   ownerBy: string
-  ownerAvatarUrl: string
 
   videoChannelBy?: string
-  videoChannelAvatarUrl?: string
-
-  private thumbnailVersion: number
-  private originThumbnailUrl: string
 
   constructor (hash: ServerVideoPlaylist, translations: {}) {
     const absoluteAPIUrl = getAbsoluteAPIUrl()
 
     this.id = hash.id
     this.uuid = hash.uuid
+    this.url = hash.url
     this.isLocal = hash.isLocal
 
     this.displayName = hash.displayName
@@ -56,12 +56,12 @@ export class VideoPlaylist implements ServerVideoPlaylist {
 
     this.thumbnailPath = hash.thumbnailPath
 
-    if (this.thumbnailPath) {
-      this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath
-      this.originThumbnailUrl = this.thumbnailUrl
-    } else {
-      this.thumbnailUrl = window.location.origin + '/client/assets/images/default-playlist.jpg'
-    }
+    this.thumbnailUrl = this.thumbnailPath
+      ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
+      : absoluteAPIUrl + '/client/assets/images/default-playlist.jpg'
+
+    this.embedPath = hash.embedPath
+    this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
 
     this.videosLength = hash.videosLength
 
@@ -72,12 +72,10 @@ export class VideoPlaylist implements ServerVideoPlaylist {
 
     this.ownerAccount = hash.ownerAccount
     this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
-    this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount)
 
     if (hash.videoChannel) {
       this.videoChannel = hash.videoChannel
       this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
-      this.videoChannelAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.videoChannel)
     }
 
     this.privacy.label = peertubeTranslate(this.privacy.label, translations)
@@ -86,13 +84,4 @@ export class VideoPlaylist implements ServerVideoPlaylist {
       this.displayName = peertubeTranslate(this.displayName, translations)
     }
   }
-
-  refreshThumbnail () {
-    if (!this.originThumbnailUrl) return
-
-    if (!this.thumbnailVersion) this.thumbnailVersion = 0
-    this.thumbnailVersion++
-
-    this.thumbnailUrl = this.originThumbnailUrl + '?v' + this.thumbnailVersion
-  }
 }