aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/account/account-videos
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/account/account-videos')
-rw-r--r--client/src/app/account/account-videos/account-videos.component.ts80
1 files changed, 37 insertions, 43 deletions
diff --git a/client/src/app/account/account-videos/account-videos.component.ts b/client/src/app/account/account-videos/account-videos.component.ts
index e9d044dbf..a286bad1c 100644
--- a/client/src/app/account/account-videos/account-videos.component.ts
+++ b/client/src/app/account/account-videos/account-videos.component.ts
@@ -56,55 +56,49 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit
56 return this.videoService.getMyVideos(newPagination, this.sort) 56 return this.videoService.getMyVideos(newPagination, this.sort)
57 } 57 }
58 58
59 deleteSelectedVideos () { 59 async deleteSelectedVideos () {
60 const toDeleteVideosIds = Object.keys(this.checkedVideos) 60 const toDeleteVideosIds = Object.keys(this.checkedVideos)
61 .filter(k => this.checkedVideos[k] === true) 61 .filter(k => this.checkedVideos[k] === true)
62 .map(k => parseInt(k, 10)) 62 .map(k => parseInt(k, 10))
63 63
64 this.confirmService.confirm(`Do you really want to delete ${toDeleteVideosIds.length} videos?`, 'Delete').subscribe( 64 const res = await this.confirmService.confirm(`Do you really want to delete ${toDeleteVideosIds.length} videos?`, 'Delete')
65 res => { 65 if (res === false) return
66 if (res === false) return 66
67 67 const observables: Observable<any>[] = []
68 const observables: Observable<any>[] = [] 68 for (const videoId of toDeleteVideosIds) {
69 for (const videoId of toDeleteVideosIds) { 69 const o = this.videoService
70 const o = this.videoService 70 .removeVideo(videoId)
71 .removeVideo(videoId) 71 .do(() => this.spliceVideosById(videoId))
72 .do(() => this.spliceVideosById(videoId)) 72
73 73 observables.push(o)
74 observables.push(o) 74 }
75 } 75
76 76 Observable.from(observables)
77 Observable.from(observables) 77 .concatAll()
78 .concatAll() 78 .subscribe(
79 .subscribe( 79 res => {
80 res => { 80 this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`)
81 this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`) 81 this.buildVideoPages()
82 this.buildVideoPages() 82 },
83 }, 83
84 84 err => this.notificationsService.error('Error', err.message)
85 err => this.notificationsService.error('Error', err.message) 85 )
86 )
87 }
88 )
89 } 86 }
90 87
91 deleteVideo (video: Video) { 88 async deleteVideo (video: Video) {
92 this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete').subscribe( 89 const res = await this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete')
93 res => { 90 if (res === false) return
94 if (res === false) return 91
95 92 this.videoService.removeVideo(video.id)
96 this.videoService.removeVideo(video.id) 93 .subscribe(
97 .subscribe( 94 status => {
98 status => { 95 this.notificationsService.success('Success', `Video ${video.name} deleted.`)
99 this.notificationsService.success('Success', `Video ${video.name} deleted.`) 96 this.spliceVideosById(video.id)
100 this.spliceVideosById(video.id) 97 this.buildVideoPages()
101 this.buildVideoPages() 98 },
102 }, 99
103 100 error => this.notificationsService.error('Error', error.message)
104 error => this.notificationsService.error('Error', error.message) 101 )
105 )
106 }
107 )
108 } 102 }
109 103
110 private spliceVideosById (id: number) { 104 private spliceVideosById (id: number) {