aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-17 16:02:38 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-06-25 14:44:01 +0200
commit37a44fc915eef2140e22ceb96aba6b6eb2509007 (patch)
treedd4a370ecc96cf38c99b940261aadc27065da7ae /client/src/app/shared
parent33eb19e5199cc9fa4d73c6675c97508e3e072ef9 (diff)
downloadPeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.gz
PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.zst
PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.zip
Add ability to search playlists
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-main/angular/index.ts1
-rw-r--r--client/src/app/shared/shared-main/angular/link.component.html11
-rw-r--r--client/src/app/shared/shared-main/angular/link.component.scss7
-rw-r--r--client/src/app/shared/shared-main/angular/link.component.ts17
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts7
-rw-r--r--client/src/app/shared/shared-search/search.service.ts44
-rw-r--r--client/src/app/shared/shared-video-miniature/video-miniature.component.html13
-rw-r--r--client/src/app/shared/shared-video-miniature/video-miniature.component.ts5
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html15
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss3
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts47
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist.model.ts31
12 files changed, 152 insertions, 49 deletions
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts
index 8ea47bb33..069b7f654 100644
--- a/client/src/app/shared/shared-main/angular/index.ts
+++ b/client/src/app/shared/shared-main/angular/index.ts
@@ -3,5 +3,6 @@ export * from './bytes.pipe'
3export * from './duration-formatter.pipe' 3export * from './duration-formatter.pipe'
4export * from './from-now.pipe' 4export * from './from-now.pipe'
5export * from './infinite-scroller.directive' 5export * from './infinite-scroller.directive'
6export * from './link.component'
6export * from './number-formatter.pipe' 7export * from './number-formatter.pipe'
7export * from './peertube-template.directive' 8export * from './peertube-template.directive'
diff --git a/client/src/app/shared/shared-main/angular/link.component.html b/client/src/app/shared/shared-main/angular/link.component.html
new file mode 100644
index 000000000..e61a1e085
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/link.component.html
@@ -0,0 +1,11 @@
1<ng-template #content>
2 <ng-content></ng-content>
3</ng-template>
4
5<a *ngIf="!href" [routerLink]="internalLink" [attr.title]="title" [tabindex]="tabindex">
6 <ng-template *ngTemplateOutlet="content"></ng-template>
7</a>
8
9<a *ngIf="href" [href]="href" [target]="target" [attr.title]="title" [tabindex]="tabindex">
10 <ng-template *ngTemplateOutlet="content"></ng-template>
11</a>
diff --git a/client/src/app/shared/shared-main/angular/link.component.scss b/client/src/app/shared/shared-main/angular/link.component.scss
new file mode 100644
index 000000000..bb86d5488
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/link.component.scss
@@ -0,0 +1,7 @@
1a {
2 color: inherit;
3 text-decoration: inherit;
4 position: inherit;
5 width: inherit;
6 height: inherit;
7}
diff --git a/client/src/app/shared/shared-main/angular/link.component.ts b/client/src/app/shared/shared-main/angular/link.component.ts
new file mode 100644
index 000000000..76d1201b9
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/link.component.ts
@@ -0,0 +1,17 @@
1import { Component, Input, ViewEncapsulation } from '@angular/core'
2
3@Component({
4 selector: 'my-link',
5 styleUrls: [ './link.component.scss' ],
6 templateUrl: './link.component.html'
7})
8export class LinkComponent {
9 @Input() internalLink?: any[]
10
11 @Input() href?: string
12 @Input() target?: string
13
14 @Input() title?: string
15
16 @Input() tabindex: string | number
17}
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts
index c8dd01429..e5dfc59b2 100644
--- a/client/src/app/shared/shared-main/shared-main.module.ts
+++ b/client/src/app/shared/shared-main/shared-main.module.ts
@@ -4,7 +4,7 @@ import { CommonModule, DatePipe } from '@angular/common'
4import { HttpClientModule } from '@angular/common/http' 4import { HttpClientModule } from '@angular/common/http'
5import { NgModule } from '@angular/core' 5import { NgModule } from '@angular/core'
6import { FormsModule, ReactiveFormsModule } from '@angular/forms' 6import { FormsModule, ReactiveFormsModule } from '@angular/forms'
7import { ActivatedRouteSnapshot, RouterModule } from '@angular/router' 7import { RouterModule } from '@angular/router'
8import { 8import {
9 NgbButtonsModule, 9 NgbButtonsModule,
10 NgbCollapseModule, 10 NgbCollapseModule,
@@ -24,6 +24,7 @@ import {
24 DurationFormatterPipe, 24 DurationFormatterPipe,
25 FromNowPipe, 25 FromNowPipe,
26 InfiniteScrollerDirective, 26 InfiniteScrollerDirective,
27 LinkComponent,
27 NumberFormatterPipe, 28 NumberFormatterPipe,
28 PeerTubeTemplateDirective 29 PeerTubeTemplateDirective
29} from './angular' 30} from './angular'
@@ -35,11 +36,11 @@ import { FeedComponent } from './feeds'
35import { LoaderComponent, SmallLoaderComponent } from './loaders' 36import { LoaderComponent, SmallLoaderComponent } from './loaders'
36import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc' 37import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc'
37import { PluginPlaceholderComponent } from './plugins' 38import { PluginPlaceholderComponent } from './plugins'
39import { ActorRedirectGuard } from './router'
38import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' 40import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users'
39import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' 41import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video'
40import { VideoCaptionService } from './video-caption' 42import { VideoCaptionService } from './video-caption'
41import { VideoChannelService } from './video-channel' 43import { VideoChannelService } from './video-channel'
42import { ActorRedirectGuard } from './router'
43 44
44@NgModule({ 45@NgModule({
45 imports: [ 46 imports: [
@@ -76,6 +77,7 @@ import { ActorRedirectGuard } from './router'
76 77
77 InfiniteScrollerDirective, 78 InfiniteScrollerDirective,
78 PeerTubeTemplateDirective, 79 PeerTubeTemplateDirective,
80 LinkComponent,
79 81
80 ActionDropdownComponent, 82 ActionDropdownComponent,
81 ButtonComponent, 83 ButtonComponent,
@@ -130,6 +132,7 @@ import { ActorRedirectGuard } from './router'
130 132
131 InfiniteScrollerDirective, 133 InfiniteScrollerDirective,
132 PeerTubeTemplateDirective, 134 PeerTubeTemplateDirective,
135 LinkComponent,
133 136
134 ActionDropdownComponent, 137 ActionDropdownComponent,
135 ButtonComponent, 138 ButtonComponent,
diff --git a/client/src/app/shared/shared-search/search.service.ts b/client/src/app/shared/shared-search/search.service.ts
index 15c4a7012..ad258f5e5 100644
--- a/client/src/app/shared/shared-search/search.service.ts
+++ b/client/src/app/shared/shared-search/search.service.ts
@@ -3,10 +3,17 @@ import { catchError, map, switchMap } from 'rxjs/operators'
3import { HttpClient, HttpParams } from '@angular/common/http' 3import { HttpClient, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core' 5import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core'
6import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
7import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' 6import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
8import { ResultList, SearchTargetType, Video as VideoServerModel, VideoChannel as VideoChannelServerModel } from '@shared/models' 7import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
8import {
9 ResultList,
10 SearchTargetType,
11 Video as VideoServerModel,
12 VideoChannel as VideoChannelServerModel,
13 VideoPlaylist as VideoPlaylistServerModel
14} from '@shared/models'
9import { environment } from '../../../environments/environment' 15import { environment } from '../../../environments/environment'
16import { VideoPlaylist, VideoPlaylistService } from '../shared-video-playlist'
10import { AdvancedSearch } from './advanced-search.model' 17import { AdvancedSearch } from './advanced-search.model'
11 18
12@Injectable() 19@Injectable()
@@ -17,7 +24,8 @@ export class SearchService {
17 private authHttp: HttpClient, 24 private authHttp: HttpClient,
18 private restExtractor: RestExtractor, 25 private restExtractor: RestExtractor,
19 private restService: RestService, 26 private restService: RestService,
20 private videoService: VideoService 27 private videoService: VideoService,
28 private playlistService: VideoPlaylistService
21 ) { 29 ) {
22 // Add ability to override search endpoint if the user updated this local storage key 30 // Add ability to override search endpoint if the user updated this local storage key
23 const searchUrl = peertubeLocalStorage.getItem('search-url') 31 const searchUrl = peertubeLocalStorage.getItem('search-url')
@@ -85,4 +93,34 @@ export class SearchService {
85 catchError(err => this.restExtractor.handleError(err)) 93 catchError(err => this.restExtractor.handleError(err))
86 ) 94 )
87 } 95 }
96
97 searchVideoPlaylists (parameters: {
98 search: string,
99 searchTarget?: SearchTargetType,
100 componentPagination?: ComponentPaginationLight
101 }): Observable<ResultList<VideoPlaylist>> {
102 const { search, componentPagination, searchTarget } = parameters
103
104 const url = SearchService.BASE_SEARCH_URL + 'video-playlists'
105
106 let pagination: RestPagination
107 if (componentPagination) {
108 pagination = this.restService.componentPaginationToRestPagination(componentPagination)
109 }
110
111 let params = new HttpParams()
112 params = this.restService.addRestGetParams(params, pagination)
113 params = params.append('search', search)
114
115 if (searchTarget) {
116 params = params.append('searchTarget', searchTarget as string)
117 }
118
119 return this.authHttp
120 .get<ResultList<VideoPlaylistServerModel>>(url, { params })
121 .pipe(
122 switchMap(res => this.playlistService.extractPlaylists(res)),
123 catchError(err => this.restExtractor.handleError(err))
124 )
125 }
88} 126}
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.html b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
index 6c34123ed..7765d5be7 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
@@ -21,13 +21,12 @@
21 ></my-actor-avatar> 21 ></my-actor-avatar>
22 22
23 <div class="w-100 d-flex flex-column"> 23 <div class="w-100 d-flex flex-column">
24 <a *ngIf="!videoHref" tabindex="-1" class="video-miniature-name" 24 <my-link
25 [routerLink]="videoRouterLink" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" 25 [internalLink]="videoRouterLink" [href]="videoHref" [target]="videoTarget"
26 >{{ video.name }}</a> 26 [title]="video.name"class="video-miniature-name" [ngClass]="{ 'blur-filter': isVideoBlur }" tabindex="-1"
27 27 >
28 <a *ngIf="videoHref" tabindex="-1" class="video-miniature-name" 28 {{ video.name }}
29 [href]="videoHref" [target]="videoTarget" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" 29 </my-link>
30 >{{ video.name }}</a>
31 30
32 <span class="video-miniature-created-at-views"> 31 <span class="video-miniature-created-at-views">
33 <my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle> 32 <my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle>
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
index fc066846a..fe161c977 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
@@ -12,6 +12,7 @@ import {
12} from '@angular/core' 12} from '@angular/core'
13import { AuthService, ScreenService, ServerService, User } from '@app/core' 13import { AuthService, ScreenService, ServerService, User } from '@app/core'
14import { HTMLServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models' 14import { HTMLServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models'
15import { LinkType } from '../../../types/link.type'
15import { ActorAvatarSize } from '../shared-actor-image/actor-avatar.component' 16import { ActorAvatarSize } from '../shared-actor-image/actor-avatar.component'
16import { Video } from '../shared-main' 17import { Video } from '../shared-main'
17import { VideoPlaylistService } from '../shared-video-playlist' 18import { VideoPlaylistService } from '../shared-video-playlist'
@@ -28,8 +29,6 @@ export type MiniatureDisplayOptions = {
28 blacklistInfo?: boolean 29 blacklistInfo?: boolean
29 nsfw?: boolean 30 nsfw?: boolean
30} 31}
31export type VideoLinkType = 'internal' | 'lazy-load' | 'external'
32
33@Component({ 32@Component({
34 selector: 'my-video-miniature', 33 selector: 'my-video-miniature',
35 styleUrls: [ './video-miniature.component.scss' ], 34 styleUrls: [ './video-miniature.component.scss' ],
@@ -56,7 +55,7 @@ export class VideoMiniatureComponent implements OnInit {
56 55
57 @Input() displayAsRow = false 56 @Input() displayAsRow = false
58 57
59 @Input() videoLinkType: VideoLinkType = 'internal' 58 @Input() videoLinkType: LinkType = 'internal'
60 59
61 @Output() videoBlocked = new EventEmitter() 60 @Output() videoBlocked = new EventEmitter()
62 @Output() videoUnblocked = new EventEmitter() 61 @Output() videoUnblocked = new EventEmitter()
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html
index 81c36e6fe..95f11f030 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.html
@@ -1,7 +1,7 @@
1<div class="miniature" [ngClass]="{ 'no-videos': playlist.videosLength === 0, 'to-manage': toManage, 'display-as-row': displayAsRow }"> 1<div class="miniature" [ngClass]="{ 'no-videos': playlist.videosLength === 0, 'to-manage': toManage, 'display-as-row': displayAsRow }">
2 <a 2 <my-link
3 [routerLink]="getPlaylistUrl()" [attr.title]="playlist.description" 3 [internalLink]="routerLink" [href]="playlistHref" [target]="playlistTarget"
4 class="miniature-thumbnail" 4 [title]="playlist.description" class="miniature-thumbnail"
5 > 5 >
6 <img alt="" [attr.aria-labelledby]="playlist.displayName" [attr.src]="playlist.thumbnailUrl" /> 6 <img alt="" [attr.aria-labelledby]="playlist.displayName" [attr.src]="playlist.thumbnailUrl" />
7 7
@@ -12,12 +12,15 @@
12 <div class="play-overlay"> 12 <div class="play-overlay">
13 <div class="icon"></div> 13 <div class="icon"></div>
14 </div> 14 </div>
15 </a> 15 </my-link>
16 16
17 <div class="miniature-info"> 17 <div class="miniature-info">
18 <a tabindex="-1" class="miniature-name" [routerLink]="getPlaylistUrl()" [attr.title]="playlist.description"> 18 <my-link
19 [internalLink]="routerLink" [href]="playlistHref" [target]="playlistTarget"
20 [title]="playlist.description" class="miniature-name" tabindex="-1"
21 >
19 {{ playlist.displayName }} 22 {{ playlist.displayName }}
20 </a> 23 </my-link>
21 24
22 <a i18n [routerLink]="[ '/c', playlist.videoChannelBy ]" class="by" *ngIf="displayChannel && playlist.videoChannelBy"> 25 <a i18n [routerLink]="[ '/c', playlist.videoChannelBy ]" class="by" *ngIf="displayChannel && playlist.videoChannelBy">
23 {{ playlist.videoChannelBy }} 26 {{ playlist.videoChannelBy }}
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss
index 95bf469ac..cf7513984 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.scss
@@ -75,7 +75,10 @@
75} 75}
76 76
77.miniature:not(.display-as-row) { 77.miniature:not(.display-as-row) {
78
78 .miniature-thumbnail { 79 .miniature-thumbnail {
80 @include block-ratio($selector: '::ng-deep a');
81
79 margin-top: 10px; 82 margin-top: 10px;
80 margin-bottom: 5px; 83 margin-bottom: 5px;
81 } 84 }
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
index 9bbec6038..8de5092a9 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
@@ -1,4 +1,5 @@
1import { Component, Input } from '@angular/core' 1import { LinkType } from 'src/types/link.type'
2import { Component, Input, OnInit } from '@angular/core'
2import { VideoPlaylist } from './video-playlist.model' 3import { VideoPlaylist } from './video-playlist.model'
3 4
4@Component({ 5@Component({
@@ -6,18 +7,52 @@ import { VideoPlaylist } from './video-playlist.model'
6 styleUrls: [ './video-playlist-miniature.component.scss' ], 7 styleUrls: [ './video-playlist-miniature.component.scss' ],
7 templateUrl: './video-playlist-miniature.component.html' 8 templateUrl: './video-playlist-miniature.component.html'
8}) 9})
9export class VideoPlaylistMiniatureComponent { 10export class VideoPlaylistMiniatureComponent implements OnInit {
10 @Input() playlist: VideoPlaylist 11 @Input() playlist: VideoPlaylist
12
11 @Input() toManage = false 13 @Input() toManage = false
14
12 @Input() displayChannel = false 15 @Input() displayChannel = false
13 @Input() displayDescription = false 16 @Input() displayDescription = false
14 @Input() displayPrivacy = false 17 @Input() displayPrivacy = false
15 @Input() displayAsRow = false 18 @Input() displayAsRow = false
16 19
17 getPlaylistUrl () { 20 @Input() linkType: LinkType = 'internal'
18 if (this.toManage) return [ '/my-library/video-playlists', this.playlist.uuid ] 21
19 if (this.playlist.videosLength === 0) return null 22 routerLink: any
23 playlistHref: string
24 playlistTarget: string
25
26 ngOnInit () {
27 this.buildPlaylistUrl()
28 }
29
30 buildPlaylistUrl () {
31 if (this.toManage) {
32 this.routerLink = [ '/my-library/video-playlists', this.playlist.uuid ]
33 return
34 }
35
36 if (this.playlist.videosLength === 0) {
37 this.routerLink = null
38 return
39 }
40
41 if (this.linkType === 'internal' || !this.playlist.url) {
42 this.routerLink = [ '/w/p', this.playlist.uuid ]
43 return
44 }
45
46 if (this.linkType === 'external') {
47 this.routerLink = null
48 this.playlistHref = this.playlist.url
49 this.playlistTarget = '_blank'
50 return
51 }
52
53 // Lazy load
54 this.routerLink = [ '/search/lazy-load-playlist', { url: this.playlist.url } ]
20 55
21 return [ '/w/p', this.playlist.uuid ] 56 return
22 } 57 }
23} 58}
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
index 5b6ba9dbf..d67f372f4 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
@@ -1,5 +1,5 @@
1import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' 1import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
2import { Account, Actor, VideoChannel } from '@app/shared/shared-main' 2import { Actor } from '@app/shared/shared-main'
3import { peertubeTranslate } from '@shared/core-utils/i18n' 3import { peertubeTranslate } from '@shared/core-utils/i18n'
4import { 4import {
5 AccountSummary, 5 AccountSummary,
@@ -15,12 +15,12 @@ export class VideoPlaylist implements ServerVideoPlaylist {
15 uuid: string 15 uuid: string
16 isLocal: boolean 16 isLocal: boolean
17 17
18 url: string
19
18 displayName: string 20 displayName: string
19 description: string 21 description: string
20 privacy: VideoConstant<VideoPlaylistPrivacy> 22 privacy: VideoConstant<VideoPlaylistPrivacy>
21 23
22 thumbnailPath: string
23
24 videosLength: number 24 videosLength: number
25 25
26 type: VideoConstant<VideoPlaylistType> 26 type: VideoConstant<VideoPlaylistType>
@@ -31,6 +31,7 @@ export class VideoPlaylist implements ServerVideoPlaylist {
31 ownerAccount: AccountSummary 31 ownerAccount: AccountSummary
32 videoChannel?: VideoChannelSummary 32 videoChannel?: VideoChannelSummary
33 33
34 thumbnailPath: string
34 thumbnailUrl: string 35 thumbnailUrl: string
35 36
36 embedPath: string 37 embedPath: string
@@ -40,14 +41,12 @@ export class VideoPlaylist implements ServerVideoPlaylist {
40 41
41 videoChannelBy?: string 42 videoChannelBy?: string
42 43
43 private thumbnailVersion: number
44 private originThumbnailUrl: string
45
46 constructor (hash: ServerVideoPlaylist, translations: {}) { 44 constructor (hash: ServerVideoPlaylist, translations: {}) {
47 const absoluteAPIUrl = getAbsoluteAPIUrl() 45 const absoluteAPIUrl = getAbsoluteAPIUrl()
48 46
49 this.id = hash.id 47 this.id = hash.id
50 this.uuid = hash.uuid 48 this.uuid = hash.uuid
49 this.url = hash.url
51 this.isLocal = hash.isLocal 50 this.isLocal = hash.isLocal
52 51
53 this.displayName = hash.displayName 52 this.displayName = hash.displayName
@@ -57,15 +56,12 @@ export class VideoPlaylist implements ServerVideoPlaylist {
57 56
58 this.thumbnailPath = hash.thumbnailPath 57 this.thumbnailPath = hash.thumbnailPath
59 58
60 if (this.thumbnailPath) { 59 this.thumbnailUrl = this.thumbnailPath
61 this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath 60 ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
62 this.originThumbnailUrl = this.thumbnailUrl 61 : absoluteAPIUrl + '/client/assets/images/default-playlist.jpg'
63 } else {
64 this.thumbnailUrl = window.location.origin + '/client/assets/images/default-playlist.jpg'
65 }
66 62
67 this.embedPath = hash.embedPath 63 this.embedPath = hash.embedPath
68 this.embedUrl = getAbsoluteEmbedUrl() + hash.embedPath 64 this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
69 65
70 this.videosLength = hash.videosLength 66 this.videosLength = hash.videosLength
71 67
@@ -88,13 +84,4 @@ export class VideoPlaylist implements ServerVideoPlaylist {
88 this.displayName = peertubeTranslate(this.displayName, translations) 84 this.displayName = peertubeTranslate(this.displayName, translations)
89 } 85 }
90 } 86 }
91
92 refreshThumbnail () {
93 if (!this.originThumbnailUrl) return
94
95 if (!this.thumbnailVersion) this.thumbnailVersion = 0
96 this.thumbnailVersion++
97
98 this.thumbnailUrl = this.originThumbnailUrl + '?v' + this.thumbnailVersion
99 }
100} 87}