]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-video-playlist/video-playlist.model.ts
Fix ngx loading bar deprecation
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-playlist / video-playlist.model.ts
index 3db3b7a2e4156f4df4a7afd585cceeaf0af58a55..6b38d9ca351bc8814857e34bc8ae1d35c99ad2e7 100644 (file)
@@ -1,5 +1,6 @@
 import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
 import { Actor } from '@app/shared/shared-main'
 import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
 import { Actor } from '@app/shared/shared-main'
+import { buildPlaylistWatchPath } from '@shared/core-utils'
 import { peertubeTranslate } from '@shared/core-utils/i18n'
 import {
   AccountSummary,
 import { peertubeTranslate } from '@shared/core-utils/i18n'
 import {
   AccountSummary,
@@ -13,14 +14,16 @@ import {
 export class VideoPlaylist implements ServerVideoPlaylist {
   id: number
   uuid: string
 export class VideoPlaylist implements ServerVideoPlaylist {
   id: number
   uuid: string
+  shortUUID: string
+
   isLocal: boolean
 
   isLocal: boolean
 
+  url: string
+
   displayName: string
   description: string
   privacy: VideoConstant<VideoPlaylistPrivacy>
 
   displayName: string
   description: string
   privacy: VideoConstant<VideoPlaylistPrivacy>
 
-  thumbnailPath: string
-
   videosLength: number
 
   type: VideoConstant<VideoPlaylistType>
   videosLength: number
 
   type: VideoConstant<VideoPlaylistType>
@@ -31,25 +34,28 @@ export class VideoPlaylist implements ServerVideoPlaylist {
   ownerAccount: AccountSummary
   videoChannel?: VideoChannelSummary
 
   ownerAccount: AccountSummary
   videoChannel?: VideoChannelSummary
 
+  thumbnailPath: string
   thumbnailUrl: string
 
   embedPath: string
   embedUrl: string
 
   ownerBy: string
   thumbnailUrl: string
 
   embedPath: string
   embedUrl: string
 
   ownerBy: string
-  ownerAvatarUrl: string
 
   videoChannelBy?: string
 
   videoChannelBy?: string
-  videoChannelAvatarUrl?: string
 
 
-  private thumbnailVersion: number
-  private originThumbnailUrl: string
+  static buildWatchUrl (playlist: Pick<VideoPlaylist, 'uuid' | 'shortUUID'>) {
+    return buildPlaylistWatchPath({ shortUUID: playlist.shortUUID || playlist.uuid })
+  }
 
 
-  constructor (hash: ServerVideoPlaylist, translations: {}) {
+  constructor (hash: ServerVideoPlaylist, translations: { [ id: string ]: string }) {
     const absoluteAPIUrl = getAbsoluteAPIUrl()
 
     this.id = hash.id
     this.uuid = hash.uuid
     const absoluteAPIUrl = getAbsoluteAPIUrl()
 
     this.id = hash.id
     this.uuid = hash.uuid
+    this.shortUUID = hash.shortUUID
+
+    this.url = hash.url
     this.isLocal = hash.isLocal
 
     this.displayName = hash.displayName
     this.isLocal = hash.isLocal
 
     this.displayName = hash.displayName
@@ -59,15 +65,12 @@ export class VideoPlaylist implements ServerVideoPlaylist {
 
     this.thumbnailPath = hash.thumbnailPath
 
 
     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.embedPath = hash.embedPath
-    this.embedUrl = getAbsoluteEmbedUrl() + hash.embedPath
+    this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
 
     this.videosLength = hash.videosLength
 
 
     this.videosLength = hash.videosLength
 
@@ -78,12 +81,10 @@ export class VideoPlaylist implements ServerVideoPlaylist {
 
     this.ownerAccount = hash.ownerAccount
     this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
 
     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)
 
     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)
     }
 
     this.privacy.label = peertubeTranslate(this.privacy.label, translations)
@@ -92,13 +93,4 @@ export class VideoPlaylist implements ServerVideoPlaylist {
       this.displayName = peertubeTranslate(this.displayName, translations)
     }
   }
       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
-  }
 }
 }