aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts')
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts75
1 files changed, 38 insertions, 37 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
index 62aaeb019..fef1f5d65 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
@@ -88,40 +88,41 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
88 88
89 this.loadingBar.useRef().start() 89 this.loadingBar.useRef().start()
90 90
91 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe( 91 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate)
92 res => { 92 .subscribe({
93 this.loadingBar.useRef().complete() 93 next: res => {
94 this.firstStepDone.emit(res.video.name) 94 this.loadingBar.useRef().complete()
95 this.isImportingVideo = false 95 this.firstStepDone.emit(res.video.name)
96 this.hasImportedVideo = true 96 this.isImportingVideo = false
97 97 this.hasImportedVideo = true
98 this.video = new VideoEdit(Object.assign(res.video, { 98
99 commentsEnabled: videoUpdate.commentsEnabled, 99 this.video = new VideoEdit(Object.assign(res.video, {
100 downloadEnabled: videoUpdate.downloadEnabled, 100 commentsEnabled: videoUpdate.commentsEnabled,
101 privacy: { id: this.firstStepPrivacyId }, 101 downloadEnabled: videoUpdate.downloadEnabled,
102 support: null, 102 privacy: { id: this.firstStepPrivacyId },
103 thumbnailUrl: null, 103 support: null,
104 previewUrl: null 104 thumbnailUrl: null,
105 })) 105 previewUrl: null
106 106 }))
107 hydrateFormFromVideo(this.form, this.video, false) 107
108 }, 108 hydrateFormFromVideo(this.form, this.video, false)
109 109 },
110 err => { 110
111 this.loadingBar.useRef().complete() 111 error: err => {
112 this.isImportingVideo = false 112 this.loadingBar.useRef().complete()
113 this.firstStepError.emit() 113 this.isImportingVideo = false
114 114 this.firstStepError.emit()
115 let message = err.message 115
116 116 let message = err.message
117 const error = err.body as PeerTubeProblemDocument 117
118 if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) { 118 const error = err.body as PeerTubeProblemDocument
119 message = $localize`Torrents with only 1 file are supported.` 119 if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) {
120 } 120 message = $localize`Torrents with only 1 file are supported.`
121 }
121 122
122 this.notifier.error(message) 123 this.notifier.error(message)
123 } 124 }
124 ) 125 })
125 } 126 }
126 127
127 updateSecondStep () { 128 updateSecondStep () {
@@ -135,19 +136,19 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
135 136
136 // Update the video 137 // Update the video
137 this.updateVideoAndCaptions(this.video) 138 this.updateVideoAndCaptions(this.video)
138 .subscribe( 139 .subscribe({
139 () => { 140 next: () => {
140 this.isUpdatingVideo = false 141 this.isUpdatingVideo = false
141 this.notifier.success($localize`Video to import updated.`) 142 this.notifier.success($localize`Video to import updated.`)
142 143
143 this.router.navigate([ '/my-library', 'video-imports' ]) 144 this.router.navigate([ '/my-library', 'video-imports' ])
144 }, 145 },
145 146
146 err => { 147 error: err => {
147 this.error = err.message 148 this.error = err.message
148 scrollToTop() 149 scrollToTop()
149 console.error(err) 150 console.error(err)
150 } 151 }
151 ) 152 })
152 } 153 }
153} 154}