From 43912a30e316707c6d41677b404f19dd3cd277a5 Mon Sep 17 00:00:00 2001 From: jojohoch <joachim.hoch@iqb.hu-berlin.de> Date: Fri, 21 Apr 2023 10:37:57 +0200 Subject: [PATCH] [player] Unsubscribe section from media change events after it's visible --- .../directives/section-visibility-handling.directive.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/player/src/app/directives/section-visibility-handling.directive.ts b/projects/player/src/app/directives/section-visibility-handling.directive.ts index 3bdac732c..a40f0c3d4 100644 --- a/projects/player/src/app/directives/section-visibility-handling.directive.ts +++ b/projects/player/src/app/directives/section-visibility-handling.directive.ts @@ -1,5 +1,5 @@ import { Directive, ElementRef, Input } from '@angular/core'; -import { delay, Subject } from 'rxjs'; +import { delay, Subject, Subscription } from 'rxjs'; import { Section } from 'common/models/section'; import { takeUntil } from 'rxjs/operators'; import { ElementCodeStatusValue } from 'player/modules/verona/models/verona'; @@ -28,7 +28,11 @@ export class SectionVisibilityHandlingDirective { .pipe( takeUntil(this.ngUnsubscribe), delay(this.section.activeAfterIdDelay)) - .subscribe((id: string): void => this.setActiveAfterID(id)); + .subscribe((id: string): void => { + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); + this.setActiveAfterID(id); + }); } } -- GitLab