Fix video playlist element removal
This commit is contained in:
parent
ebe7f58726
commit
a3671f0709
|
@ -12,6 +12,7 @@ type PlaylistSummary = {
|
||||||
inPlaylist: boolean
|
inPlaylist: boolean
|
||||||
displayName: string
|
displayName: string
|
||||||
|
|
||||||
|
playlistElementId?: number
|
||||||
startTimestamp?: number
|
startTimestamp?: number
|
||||||
stopTimestamp?: number
|
stopTimestamp?: number
|
||||||
}
|
}
|
||||||
|
@ -37,8 +38,6 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
|
||||||
}
|
}
|
||||||
displayOptions = false
|
displayOptions = false
|
||||||
|
|
||||||
private playlistElementId: number
|
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
protected formValidatorService: FormValidatorService,
|
protected formValidatorService: FormValidatorService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
|
@ -95,11 +94,10 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
|
||||||
id: playlist.id,
|
id: playlist.id,
|
||||||
displayName: playlist.displayName,
|
displayName: playlist.displayName,
|
||||||
inPlaylist: !!existingPlaylist,
|
inPlaylist: !!existingPlaylist,
|
||||||
|
playlistElementId: existingPlaylist ? existingPlaylist.playlistElementId : undefined,
|
||||||
startTimestamp: existingPlaylist ? existingPlaylist.startTimestamp : undefined,
|
startTimestamp: existingPlaylist ? existingPlaylist.startTimestamp : undefined,
|
||||||
stopTimestamp: existingPlaylist ? existingPlaylist.stopTimestamp : undefined
|
stopTimestamp: existingPlaylist ? existingPlaylist.stopTimestamp : undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
this.playlistElementId = existingPlaylist ? existingPlaylist.playlistElementId : undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cd.markForCheck()
|
this.cd.markForCheck()
|
||||||
|
@ -181,14 +179,15 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeVideoFromPlaylist (playlist: PlaylistSummary) {
|
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(
|
.subscribe(
|
||||||
() => {
|
() => {
|
||||||
this.notifier.success(this.i18n('Video removed from {{name}}', { name: playlist.displayName }))
|
this.notifier.success(this.i18n('Video removed from {{name}}', { name: playlist.displayName }))
|
||||||
|
|
||||||
playlist.inPlaylist = false
|
playlist.inPlaylist = false
|
||||||
|
playlist.playlistElementId = undefined
|
||||||
},
|
},
|
||||||
|
|
||||||
err => {
|
err => {
|
||||||
|
@ -209,8 +208,9 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
|
||||||
|
|
||||||
this.videoPlaylistService.addVideoInPlaylist(playlist.id, body)
|
this.videoPlaylistService.addVideoInPlaylist(playlist.id, body)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => {
|
res => {
|
||||||
playlist.inPlaylist = true
|
playlist.inPlaylist = true
|
||||||
|
playlist.playlistElementId = res.videoPlaylistElement.id
|
||||||
|
|
||||||
playlist.startTimestamp = body.startTimestamp
|
playlist.startTimestamp = body.startTimestamp
|
||||||
playlist.stopTimestamp = body.stopTimestamp
|
playlist.stopTimestamp = body.stopTimestamp
|
||||||
|
|
|
@ -113,11 +113,10 @@ export class VideoPlaylistService {
|
||||||
}
|
}
|
||||||
|
|
||||||
addVideoInPlaylist (playlistId: number, body: VideoPlaylistElementCreate) {
|
addVideoInPlaylist (playlistId: number, body: VideoPlaylistElementCreate) {
|
||||||
return this.authHttp.post(VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + playlistId + '/videos', body)
|
const url = VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + playlistId + '/videos'
|
||||||
.pipe(
|
|
||||||
map(this.restExtractor.extractDataBool),
|
return this.authHttp.post<{ videoPlaylistElement: { id: number } }>(url, body)
|
||||||
catchError(err => this.restExtractor.handleError(err))
|
.pipe(catchError(err => this.restExtractor.handleError(err)))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVideoOfPlaylist (playlistId: number, playlistElementId: number, body: VideoPlaylistElementUpdate) {
|
updateVideoOfPlaylist (playlistId: number, playlistElementId: number, body: VideoPlaylistElementUpdate) {
|
||||||
|
|
Loading…
Reference in New Issue