diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-22 11:33:18 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-22 11:33:18 +0200 |
commit | a3671f0709f3f423819fcfed47a4d4879cf82780 (patch) | |
tree | 4affe5daec0dbc7b86e300e745605411a288e58b /client/src/app/shared/video-playlist/video-add-to-playlist.component.ts | |
parent | ebe7f5872617311e33dbca1f7f0d2556932c01a0 (diff) | |
download | PeerTube-a3671f0709f3f423819fcfed47a4d4879cf82780.tar.gz PeerTube-a3671f0709f3f423819fcfed47a4d4879cf82780.tar.zst PeerTube-a3671f0709f3f423819fcfed47a4d4879cf82780.zip |
Fix video playlist element removal
Diffstat (limited to 'client/src/app/shared/video-playlist/video-add-to-playlist.component.ts')
-rw-r--r-- | client/src/app/shared/video-playlist/video-add-to-playlist.component.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts index 72de84703..6380c2e51 100644 --- a/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts +++ b/client/src/app/shared/video-playlist/video-add-to-playlist.component.ts | |||
@@ -12,6 +12,7 @@ type PlaylistSummary = { | |||
12 | inPlaylist: boolean | 12 | inPlaylist: boolean |
13 | displayName: string | 13 | displayName: string |
14 | 14 | ||
15 | playlistElementId?: number | ||
15 | startTimestamp?: number | 16 | startTimestamp?: number |
16 | stopTimestamp?: number | 17 | stopTimestamp?: number |
17 | } | 18 | } |
@@ -37,8 +38,6 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, | |||
37 | } | 38 | } |
38 | displayOptions = false | 39 | displayOptions = false |
39 | 40 | ||
40 | private playlistElementId: number | ||
41 | |||
42 | constructor ( | 41 | constructor ( |
43 | protected formValidatorService: FormValidatorService, | 42 | protected formValidatorService: FormValidatorService, |
44 | private authService: AuthService, | 43 | private authService: AuthService, |
@@ -95,11 +94,10 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, | |||
95 | id: playlist.id, | 94 | id: playlist.id, |
96 | displayName: playlist.displayName, | 95 | displayName: playlist.displayName, |
97 | inPlaylist: !!existingPlaylist, | 96 | inPlaylist: !!existingPlaylist, |
97 | playlistElementId: existingPlaylist ? existingPlaylist.playlistElementId : undefined, | ||
98 | startTimestamp: existingPlaylist ? existingPlaylist.startTimestamp : undefined, | 98 | startTimestamp: existingPlaylist ? existingPlaylist.startTimestamp : undefined, |
99 | stopTimestamp: existingPlaylist ? existingPlaylist.stopTimestamp : undefined | 99 | stopTimestamp: existingPlaylist ? existingPlaylist.stopTimestamp : undefined |
100 | }) | 100 | }) |
101 | |||
102 | this.playlistElementId = existingPlaylist ? existingPlaylist.playlistElementId : undefined | ||
103 | } | 101 | } |
104 | 102 | ||
105 | this.cd.markForCheck() | 103 | this.cd.markForCheck() |
@@ -181,14 +179,15 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, | |||
181 | } | 179 | } |
182 | 180 | ||
183 | private removeVideoFromPlaylist (playlist: PlaylistSummary) { | 181 | private removeVideoFromPlaylist (playlist: PlaylistSummary) { |
184 | if (!this.playlistElementId) return | 182 | if (!playlist.playlistElementId) return |
185 | 183 | ||
186 | this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, this.playlistElementId) | 184 | this.videoPlaylistService.removeVideoFromPlaylist(playlist.id, playlist.playlistElementId) |
187 | .subscribe( | 185 | .subscribe( |
188 | () => { | 186 | () => { |
189 | this.notifier.success(this.i18n('Video removed from {{name}}', { name: playlist.displayName })) | 187 | this.notifier.success(this.i18n('Video removed from {{name}}', { name: playlist.displayName })) |
190 | 188 | ||
191 | playlist.inPlaylist = false | 189 | playlist.inPlaylist = false |
190 | playlist.playlistElementId = undefined | ||
192 | }, | 191 | }, |
193 | 192 | ||
194 | err => { | 193 | err => { |
@@ -209,8 +208,9 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit, | |||
209 | 208 | ||
210 | this.videoPlaylistService.addVideoInPlaylist(playlist.id, body) | 209 | this.videoPlaylistService.addVideoInPlaylist(playlist.id, body) |
211 | .subscribe( | 210 | .subscribe( |
212 | () => { | 211 | res => { |
213 | playlist.inPlaylist = true | 212 | playlist.inPlaylist = true |
213 | playlist.playlistElementId = res.videoPlaylistElement.id | ||
214 | 214 | ||
215 | playlist.startTimestamp = body.startTimestamp | 215 | playlist.startTimestamp = body.startTimestamp |
216 | playlist.stopTimestamp = body.stopTimestamp | 216 | playlist.stopTimestamp = body.stopTimestamp |