From b105ea604286092b4e5fd5667f2957d113278dde Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Sep 2022 13:36:59 +0200 Subject: Correctly unsubscribe upload events on destroy --- .../+video-edit/video-add-components/video-upload.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'client/src/app/+videos') 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 4a100a390..19fba2a83 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 @@ -13,6 +13,7 @@ import { isIOS } from '@root-helpers/web-browser' import { HttpStatusCode, VideoCreateResult } from '@shared/models' import { UploaderXFormData } from './uploaderx-form-data' import { VideoSend } from './video-send' +import { Subscription } from 'rxjs' @Component({ selector: 'my-video-upload', @@ -56,6 +57,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy private alreadyRefreshedToken = false + private uploadServiceSubscription: Subscription + constructor ( protected formValidatorService: FormValidatorService, protected loadingBar: LoadingBarService, @@ -87,7 +90,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily }) - this.resumableUploadService.events + this.uploadServiceSubscription = this.resumableUploadService.events .subscribe(state => this.onUploadVideoOngoing(state)) } @@ -96,7 +99,9 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy } ngOnDestroy () { - this.resumableUploadService.disconnect(); + this.resumableUploadService.disconnect() + + if (this.uploadServiceSubscription) this.uploadServiceSubscription.unsubscribe() } canDeactivate () { -- cgit v1.2.3