diff options
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.ts | 15 |
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, | |||
5 | import { ActivatedRoute, Router } from '@angular/router' | 5 | import { ActivatedRoute, Router } from '@angular/router' |
6 | import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core' | 6 | import { AuthService, CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService, UserService } from '@app/core' |
7 | import { genericUploadErrorHandler, scrollToTop } from '@app/helpers' | 7 | import { genericUploadErrorHandler, scrollToTop } from '@app/helpers' |
8 | import { FormValidatorService } from '@app/shared/shared-forms' | 8 | import { FormReactiveService } from '@app/shared/shared-forms' |
9 | import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' | 9 | import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' |
10 | import { LoadingBarService } from '@ngx-loading-bar/core' | 10 | import { LoadingBarService } from '@ngx-loading-bar/core' |
11 | import { logger } from '@root-helpers/logger' | 11 | import { logger } from '@root-helpers/logger' |
@@ -13,6 +13,7 @@ import { isIOS } from '@root-helpers/web-browser' | |||
13 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | 13 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' |
14 | import { UploaderXFormData } from './uploaderx-form-data' | 14 | import { UploaderXFormData } from './uploaderx-form-data' |
15 | import { VideoSend } from './video-send' | 15 | import { VideoSend } from './video-send' |
16 | import { 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() |