aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts')
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
index 66a3967c7..967fa9ed1 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
@@ -5,7 +5,7 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit,
5import { ActivatedRoute, Router } from '@angular/router' 5import { ActivatedRoute, Router } from '@angular/router'
6import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core' 6import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core'
7import { genericUploadErrorHandler, scrollToTop } from '@app/helpers' 7import { genericUploadErrorHandler, scrollToTop } from '@app/helpers'
8import { FormValidatorService } from '@app/shared/shared-forms' 8import { FormReactiveService } from '@app/shared/shared-forms'
9import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' 9import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
10import { LoadingBarService } from '@ngx-loading-bar/core' 10import { LoadingBarService } from '@ngx-loading-bar/core'
11import { logger } from '@root-helpers/logger' 11import { logger } from '@root-helpers/logger'
@@ -13,6 +13,7 @@ import { isIOS } from '@root-helpers/web-browser'
13import { HttpStatusCode, VideoCreateResult } from '@shared/models' 13import { HttpStatusCode, VideoCreateResult } from '@shared/models'
14import { UploaderXFormData } from './uploaderx-form-data' 14import { UploaderXFormData } from './uploaderx-form-data'
15import { VideoSend } from './video-send' 15import { VideoSend } from './video-send'
16import { Subscription } from 'rxjs'
16 17
17@Component({ 18@Component({
18 selector: 'my-video-upload', 19 selector: 'my-video-upload',
@@ -56,8 +57,10 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
56 57
57 private alreadyRefreshedToken = false 58 private alreadyRefreshedToken = false
58 59
60 private uploadServiceSubscription: Subscription
61
59 constructor ( 62 constructor (
60 protected formValidatorService: FormValidatorService, 63 protected formReactiveService: FormReactiveService,
61 protected loadingBar: LoadingBarService, 64 protected loadingBar: LoadingBarService,
62 protected notifier: Notifier, 65 protected notifier: Notifier,
63 protected authService: AuthService, 66 protected authService: AuthService,
@@ -87,7 +90,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
87 this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily 90 this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
88 }) 91 })
89 92
90 this.resumableUploadService.events 93 this.uploadServiceSubscription = this.resumableUploadService.events
91 .subscribe(state => this.onUploadVideoOngoing(state)) 94 .subscribe(state => this.onUploadVideoOngoing(state))
92 } 95 }
93 96
@@ -96,7 +99,9 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
96 } 99 }
97 100
98 ngOnDestroy () { 101 ngOnDestroy () {
99 this.cancelUpload() 102 this.resumableUploadService.disconnect()
103
104 if (this.uploadServiceSubscription) this.uploadServiceSubscription.unsubscribe()
100 } 105 }
101 106
102 canDeactivate () { 107 canDeactivate () {
@@ -131,7 +136,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
131 onUploadVideoOngoing (state: UploadState) { 136 onUploadVideoOngoing (state: UploadState) {
132 switch (state.status) { 137 switch (state.status) {
133 case 'error': { 138 case 'error': {
134 if (!this.alreadyRefreshedToken && state.response.status === HttpStatusCode.UNAUTHORIZED_401) { 139 if (!this.alreadyRefreshedToken && state.responseStatus === HttpStatusCode.UNAUTHORIZED_401) {
135 this.alreadyRefreshedToken = true 140 this.alreadyRefreshedToken = true
136 141
137 return this.refereshTokenAndRetryUpload() 142 return this.refereshTokenAndRetryUpload()