inPlaylist: boolean
displayName: string
+ playlistElementId?: number
startTimestamp?: number
stopTimestamp?: number
}
}
displayOptions = false
- private playlistElementId: number
-
constructor (
protected formValidatorService: FormValidatorService,
private authService: AuthService,
id: playlist.id,
displayName: playlist.displayName,
inPlaylist: !!existingPlaylist,
+ playlistElementId: existingPlaylist ? existingPlaylist.playlistElementId : undefined,
startTimestamp: existingPlaylist ? existingPlaylist.startTimestamp : undefined,
stopTimestamp: existingPlaylist ? existingPlaylist.stopTimestamp : undefined
})
-
- this.playlistElementId = existingPlaylist ? existingPlaylist.playlistElementId : undefined
}
this.cd.markForCheck()
}
private removeVideoFromPlaylist (playlist: PlaylistSummary) {
- if (!this.playlistElementId) return
+ if (!playlist.playlistElementId) return
- this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, this.playlistElementId)
+ this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, playlist.playlistElementId)
.subscribe(
() => {
this.notifier.success(this.i18n('Video removed from {{name}}', { name: playlist.displayName }))
playlist.inPlaylist = false
+ playlist.playlistElementId = undefined
},
err => {
this.videoPlaylistService.addVideoInPlaylist(playlist.id, body)
.subscribe(
- () => {
+ res => {
playlist.inPlaylist = true
+ playlist.playlistElementId = res.videoPlaylistElement.id
playlist.startTimestamp = body.startTimestamp
playlist.stopTimestamp = body.stopTimestamp
}
addVideoInPlaylist (playlistId: number, body: VideoPlaylistElementCreate) {
- return this.authHttp.post(VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + playlistId + '/videos', body)
- .pipe(
- map(this.restExtractor.extractDataBool),
- catchError(err => this.restExtractor.handleError(err))
- )
+ const url = VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + playlistId + '/videos'
+
+ return this.authHttp.post<{ videoPlaylistElement: { id: number } }>(url, body)
+ .pipe(catchError(err => this.restExtractor.handleError(err)))
}
updateVideoOfPlaylist (playlistId: number, playlistElementId: number, body: VideoPlaylistElementUpdate) {