diff options
Diffstat (limited to 'client/src/app/videos')
-rw-r--r-- | client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts index a5578bebd..a17d73683 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts | |||
@@ -12,6 +12,7 @@ import { FormValidatorService } from '@app/shared' | |||
12 | import { VideoCaptionService } from '@app/shared/video-caption' | 12 | import { VideoCaptionService } from '@app/shared/video-caption' |
13 | import { VideoImportService } from '@app/shared/video-import' | 13 | import { VideoImportService } from '@app/shared/video-import' |
14 | import { scrollToTop } from '@app/shared/misc/utils' | 14 | import { scrollToTop } from '@app/shared/misc/utils' |
15 | import { switchMap, map } from 'rxjs/operators' | ||
15 | 16 | ||
16 | @Component({ | 17 | @Component({ |
17 | selector: 'my-video-import-url', | 18 | selector: 'my-video-import-url', |
@@ -76,31 +77,44 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom | |||
76 | 77 | ||
77 | this.loadingBar.start() | 78 | this.loadingBar.start() |
78 | 79 | ||
79 | this.videoImportService.importVideoUrl(this.targetUrl, videoUpdate).subscribe( | 80 | this.videoImportService |
80 | res => { | 81 | .importVideoUrl(this.targetUrl, videoUpdate) |
81 | this.loadingBar.complete() | 82 | .pipe( |
82 | this.firstStepDone.emit(res.video.name) | 83 | switchMap(res => { |
83 | this.isImportingVideo = false | 84 | return this.videoCaptionService |
84 | this.hasImportedVideo = true | 85 | .listCaptions(res.video.id) |
85 | 86 | .pipe( | |
86 | this.video = new VideoEdit(Object.assign(res.video, { | 87 | map(result => ({ video: res.video, videoCaptions: result.data })) |
87 | commentsEnabled: videoUpdate.commentsEnabled, | 88 | ) |
88 | downloadEnabled: videoUpdate.downloadEnabled, | 89 | }) |
89 | support: null, | 90 | ) |
90 | thumbnailUrl: null, | 91 | .subscribe( |
91 | previewUrl: null | 92 | ({ video, videoCaptions }) => { |
92 | })) | 93 | this.loadingBar.complete() |
93 | 94 | this.firstStepDone.emit(video.name) | |
94 | this.hydrateFormFromVideo() | 95 | this.isImportingVideo = false |
95 | }, | 96 | this.hasImportedVideo = true |
96 | 97 | ||
97 | err => { | 98 | this.video = new VideoEdit(Object.assign(video, { |
98 | this.loadingBar.complete() | 99 | commentsEnabled: videoUpdate.commentsEnabled, |
99 | this.isImportingVideo = false | 100 | downloadEnabled: videoUpdate.downloadEnabled, |
100 | this.firstStepError.emit() | 101 | support: null, |
101 | this.notifier.error(err.message) | 102 | thumbnailUrl: null, |
102 | } | 103 | previewUrl: null |
103 | ) | 104 | })) |
105 | |||
106 | this.videoCaptions = videoCaptions | ||
107 | |||
108 | this.hydrateFormFromVideo() | ||
109 | }, | ||
110 | |||
111 | err => { | ||
112 | this.loadingBar.complete() | ||
113 | this.isImportingVideo = false | ||
114 | this.firstStepError.emit() | ||
115 | this.notifier.error(err.message) | ||
116 | } | ||
117 | ) | ||
104 | } | 118 | } |
105 | 119 | ||
106 | updateSecondStep () { | 120 | updateSecondStep () { |