aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-02-22 11:41:44 +0100
committerChocobozzz <me@florianbigard.com>2022-02-22 11:41:44 +0100
commit89e3de8dc6dbe3c78aefb5f43e0feffd97b1af02 (patch)
tree23503491d333915b9daea29cef1a0e1d90bb1344 /client/src/app
parent4edee628a0a154360b30eab48924b3987ac90798 (diff)
downloadPeerTube-89e3de8dc6dbe3c78aefb5f43e0feffd97b1af02.tar.gz
PeerTube-89e3de8dc6dbe3c78aefb5f43e0feffd97b1af02.tar.zst
PeerTube-89e3de8dc6dbe3c78aefb5f43e0feffd97b1af02.zip
Reduce latency when adding a video to playlist
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts
index 553930595..e4972ec10 100644
--- a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts
+++ b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts
@@ -56,6 +56,8 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
56 private listenToPlaylistChangeSub: Subscription 56 private listenToPlaylistChangeSub: Subscription
57 private playlistsData: CachedPlaylist[] = [] 57 private playlistsData: CachedPlaylist[] = []
58 58
59 private pendingAddId: number
60
59 constructor ( 61 constructor (
60 protected formValidatorService: FormValidatorService, 62 protected formValidatorService: FormValidatorService,
61 private authService: AuthService, 63 private authService: AuthService,
@@ -215,8 +217,9 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
215 } 217 }
216 218
217 isPrimaryCheckboxChecked (playlist: PlaylistSummary) { 219 isPrimaryCheckboxChecked (playlist: PlaylistSummary) {
218 return playlist.elements.filter(e => e.enabled) 220 // Reduce latency when adding a video to a playlist using pendingAddId
219 .length !== 0 221 return this.pendingAddId === playlist.id ||
222 playlist.elements.filter(e => e.enabled).length !== 0
220 } 223 }
221 224
222 toggleOptionalRow (playlist: PlaylistSummary) { 225 toggleOptionalRow (playlist: PlaylistSummary) {
@@ -367,6 +370,8 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
367 if (element.startTimestamp) body.startTimestamp = element.startTimestamp 370 if (element.startTimestamp) body.startTimestamp = element.startTimestamp
368 if (element.stopTimestamp && element.stopTimestamp !== this.video.duration) body.stopTimestamp = element.stopTimestamp 371 if (element.stopTimestamp && element.stopTimestamp !== this.video.duration) body.stopTimestamp = element.stopTimestamp
369 372
373 this.pendingAddId = playlist.id
374
370 this.videoPlaylistService.addVideoInPlaylist(playlist.id, body) 375 this.videoPlaylistService.addVideoInPlaylist(playlist.id, body)
371 .subscribe({ 376 .subscribe({
372 next: res => { 377 next: res => {
@@ -379,9 +384,17 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
379 if (element) element.playlistElementId = res.videoPlaylistElement.id 384 if (element) element.playlistElementId = res.videoPlaylistElement.id
380 }, 385 },
381 386
382 error: err => this.notifier.error(err.message), 387 error: err => {
388 this.pendingAddId = undefined
389 this.cd.markForCheck()
390
391 this.notifier.error(err.message)
392 },
383 393
384 complete: () => this.cd.markForCheck() 394 complete: () => {
395 this.pendingAddId = undefined
396 this.cd.markForCheck()
397 }
385 }) 398 })
386 } 399 }
387 400