Correctly unsubscribe upload events on destroy
This commit is contained in:
parent
9d84ac5ec1
commit
b105ea6042
|
@ -13,6 +13,7 @@ import { isIOS } from '@root-helpers/web-browser'
|
||||||
import { HttpStatusCode, VideoCreateResult } from '@shared/models'
|
import { HttpStatusCode, VideoCreateResult } from '@shared/models'
|
||||||
import { UploaderXFormData } from './uploaderx-form-data'
|
import { UploaderXFormData } from './uploaderx-form-data'
|
||||||
import { VideoSend } from './video-send'
|
import { VideoSend } from './video-send'
|
||||||
|
import { Subscription } from 'rxjs'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-video-upload',
|
selector: 'my-video-upload',
|
||||||
|
@ -56,6 +57,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
|
||||||
|
|
||||||
private alreadyRefreshedToken = false
|
private alreadyRefreshedToken = false
|
||||||
|
|
||||||
|
private uploadServiceSubscription: Subscription
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
protected formValidatorService: FormValidatorService,
|
protected formValidatorService: FormValidatorService,
|
||||||
protected loadingBar: LoadingBarService,
|
protected loadingBar: LoadingBarService,
|
||||||
|
@ -87,7 +90,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
|
||||||
this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
|
this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
|
||||||
})
|
})
|
||||||
|
|
||||||
this.resumableUploadService.events
|
this.uploadServiceSubscription = this.resumableUploadService.events
|
||||||
.subscribe(state => this.onUploadVideoOngoing(state))
|
.subscribe(state => this.onUploadVideoOngoing(state))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +99,9 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy () {
|
ngOnDestroy () {
|
||||||
this.resumableUploadService.disconnect();
|
this.resumableUploadService.disconnect()
|
||||||
|
|
||||||
|
if (this.uploadServiceSubscription) this.uploadServiceSubscription.unsubscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
canDeactivate () {
|
canDeactivate () {
|
||||||
|
|
Loading…
Reference in New Issue