aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-06 13:06:13 +0100
committerChocobozzz <me@florianbigard.com>2020-01-06 13:34:08 +0100
commit51b34a11b298b466faef9c8d24beec4442d7add3 (patch)
tree57f9969eb5eb31f9b7cd8f1185927b105a3de809 /client/src/app/shared/video
parent46db9430af70f45bc656cb0ac8e519f5d0be0149 (diff)
downloadPeerTube-51b34a11b298b466faef9c8d24beec4442d7add3.tar.gz
PeerTube-51b34a11b298b466faef9c8d24beec4442d7add3.tar.zst
PeerTube-51b34a11b298b466faef9c8d24beec4442d7add3.zip
Share playlists state
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r--client/src/app/shared/video/video-miniature.component.ts49
-rw-r--r--client/src/app/shared/video/video-thumbnail.component.html2
2 files changed, 25 insertions, 26 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts
index a603f87e5..598a7a983 100644
--- a/client/src/app/shared/video/video-miniature.component.ts
+++ b/client/src/app/shared/video/video-miniature.component.ts
@@ -17,8 +17,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
17import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' 17import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component'
18import { ScreenService } from '@app/shared/misc/screen.service' 18import { ScreenService } from '@app/shared/misc/screen.service'
19import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' 19import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
20import { forkJoin } from 'rxjs' 20import { switchMap } from 'rxjs/operators'
21import { first } from 'rxjs/operators'
22 21
23export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' 22export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto'
24export type MiniatureDisplayOptions = { 23export type MiniatureDisplayOptions = {
@@ -193,7 +192,7 @@ export class VideoMiniatureComponent implements OnInit {
193 } 192 }
194 193
195 removeFromWatchLater () { 194 removeFromWatchLater () {
196 this.videoPlaylistService.removeVideoFromPlaylist(this.watchLaterPlaylist.id, this.watchLaterPlaylist.playlistElementId) 195 this.videoPlaylistService.removeVideoFromPlaylist(this.watchLaterPlaylist.id, this.watchLaterPlaylist.playlistElementId, this.video.id)
197 .subscribe( 196 .subscribe(
198 _ => { /* empty */ } 197 _ => { /* empty */ }
199 ) 198 )
@@ -222,27 +221,27 @@ export class VideoMiniatureComponent implements OnInit {
222 } 221 }
223 222
224 private loadWatchLater () { 223 private loadWatchLater () {
225 if (!this.isUserLoggedIn()) return 224 if (!this.isUserLoggedIn() || this.inWatchLaterPlaylist !== undefined) return
226 225
227 forkJoin([ 226 this.authService.userInformationLoaded
228 this.videoPlaylistService.doesVideoExistInPlaylist(this.video.id), 227 .pipe(switchMap(() => this.videoPlaylistService.listenToVideoPlaylistChange(this.video.id)))
229 this.authService.userInformationLoaded.pipe(first()) 228 .subscribe(existResult => {
230 ]).subscribe( 229 const watchLaterPlaylist = this.authService.getUser().specialPlaylists.find(p => p.type === VideoPlaylistType.WATCH_LATER)
231 ([ existResult ]) => { 230 const existsInWatchLater = existResult.find(r => r.playlistId === watchLaterPlaylist.id)
232 const watchLaterPlaylist = this.authService.getUser().specialPlaylists.find(p => p.type === VideoPlaylistType.WATCH_LATER) 231 this.inWatchLaterPlaylist = false
233 const existsInWatchLater = existResult[ this.video.id ].find(r => r.playlistId === watchLaterPlaylist.id) 232
234 this.inWatchLaterPlaylist = false 233 this.watchLaterPlaylist = {
235 234 id: watchLaterPlaylist.id
236 this.watchLaterPlaylist = { 235 }
237 id: watchLaterPlaylist.id 236
238 } 237 if (existsInWatchLater) {
239 238 this.inWatchLaterPlaylist = true
240 if (existsInWatchLater) { 239 this.watchLaterPlaylist.playlistElementId = existsInWatchLater.playlistElementId
241 this.inWatchLaterPlaylist = true 240 }
242 this.watchLaterPlaylist.playlistElementId = existsInWatchLater.playlistElementId 241
243 } 242 this.cd.markForCheck()
244 243 })
245 this.cd.markForCheck() 244
246 }) 245 this.videoPlaylistService.runPlaylistCheck(this.video.id)
247 } 246 }
248} 247}
diff --git a/client/src/app/shared/video/video-thumbnail.component.html b/client/src/app/shared/video/video-thumbnail.component.html
index c30a43557..7e71a390b 100644
--- a/client/src/app/shared/video/video-thumbnail.component.html
+++ b/client/src/app/shared/video/video-thumbnail.component.html
@@ -2,7 +2,7 @@
2 [routerLink]="getVideoRouterLink()" [queryParams]="queryParams" [attr.title]="video.name" 2 [routerLink]="getVideoRouterLink()" [queryParams]="queryParams" [attr.title]="video.name"
3 class="video-thumbnail" 3 class="video-thumbnail"
4> 4>
5 <img alt="" [attr.aria-labelledby]="video.name" [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" loading="lazy" /> 5 <img alt="" [attr.aria-labelledby]="video.name" [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" />
6 6
7 <div *ngIf="displayWatchLaterPlaylist" class="video-thumbnail-actions-overlay"> 7 <div *ngIf="displayWatchLaterPlaylist" class="video-thumbnail-actions-overlay">
8 <ng-container *ngIf="inWatchLaterPlaylist !== true"> 8 <ng-container *ngIf="inWatchLaterPlaylist !== true">