From 22a318bde2810b5eaea661b6e042dd602549ac2d Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 7 Oct 2020 17:24:44 +0200 Subject: [PATCH] Show first unstable element in autopilot Skips all unstable elements in autopilot --- client/src/app/shared/models/core/projector.ts | 12 ++++++++++++ .../cinema/components/cinema/cinema.component.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/client/src/app/shared/models/core/projector.ts b/client/src/app/shared/models/core/projector.ts index feea21a54..527eb4a66 100644 --- a/client/src/app/shared/models/core/projector.ts +++ b/client/src/app/shared/models/core/projector.ts @@ -95,6 +95,18 @@ export class Projector extends BaseModel { return [this.aspect_ratio_numerator, this.aspect_ratio_denominator].join(':'); } + public get firstUnstableElement(): ProjectorElement { + let elementIndex = 0; + /** + * while we could use a filter function to remove all stable elements, I expect + * this approach to be the fastest + */ + while (!!this.elements[elementIndex]?.stable) { + elementIndex++; + } + return this.elements[elementIndex] ?? null; + } + /** * Set the aspect ratio */ diff --git a/client/src/app/site/cinema/components/cinema/cinema.component.ts b/client/src/app/site/cinema/components/cinema/cinema.component.ts index fe004268d..3fcdf56ef 100644 --- a/client/src/app/site/cinema/components/cinema/cinema.component.ts +++ b/client/src/app/site/cinema/components/cinema/cinema.component.ts @@ -96,7 +96,7 @@ export class CinemaComponent extends BaseViewComponentDirective implements OnIni this.subscriptions.push( this.projectorRepo.getReferenceProjectorObservable().subscribe(refProjector => { this.projector = refProjector; - this.currentProjectorElement = refProjector?.elements[0] || null; + this.currentProjectorElement = refProjector?.firstUnstableElement || null; if (this.currentProjectorElement) { this.projectedViewModel = this.projectorService.getViewModelFromProjectorElement( this.currentProjectorElement