From 65af03a241aa83ab7ba71278b6c99acd26428b8a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 1 Aug 2019 16:54:24 +0200 Subject: Automatically update playlist thumbnails --- .../src/app/shared/video-playlist/video-playlist.model.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/video-playlist/video-playlist.model.ts b/client/src/app/shared/video-playlist/video-playlist.model.ts index 7e311aa54..6f27e7475 100644 --- a/client/src/app/shared/video-playlist/video-playlist.model.ts +++ b/client/src/app/shared/video-playlist/video-playlist.model.ts @@ -38,6 +38,9 @@ export class VideoPlaylist implements ServerVideoPlaylist { videoChannelBy?: string videoChannelAvatarUrl?: string + private thumbnailVersion: number + private originThumbnailUrl: string + constructor (hash: ServerVideoPlaylist, translations: {}) { const absoluteAPIUrl = getAbsoluteAPIUrl() @@ -54,6 +57,7 @@ export class VideoPlaylist implements ServerVideoPlaylist { if (this.thumbnailPath) { this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath + this.originThumbnailUrl = this.thumbnailUrl } else { this.thumbnailUrl = window.location.origin + '/client/assets/images/default-playlist.jpg' } @@ -81,4 +85,13 @@ 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 + } } -- cgit v1.2.3