From 4222674eb1101cd155c1df5218a02fa197b18854 Mon Sep 17 00:00:00 2001 From: romeonicholas Date: Tue, 28 Nov 2023 17:38:05 +0100 Subject: [PATCH] fix: replace if statement with rxjs filtering --- .../model-overview/model-overview.component.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts b/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts index a7fe60353d..72b468b76e 100644 --- a/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts +++ b/frontend/src/app/projects/project-detail/model-overview/model-overview.component.ts @@ -6,7 +6,7 @@ import { Component, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { first } from 'rxjs'; +import { first, filter } from 'rxjs'; import { ModelDiagramDialogComponent } from 'src/app/projects/models/diagrams/model-diagram-dialog/model-diagram-dialog.component'; import { getPrimaryGitModel, @@ -45,17 +45,16 @@ export class ModelOverviewComponent implements OnInit { .pipe(untilDestroyed(this)) .subscribe((project) => (this.project = project)); - this.modelService.models$.pipe(untilDestroyed(this)).subscribe((models) => { - if (models) { + this.modelService.models$ + .pipe(untilDestroyed(this), filter(Boolean)) + .subscribe((models) => { this.models = models.sort((a, b) => { if (a.display_order && b.display_order) { return a.display_order - b.display_order; - } else { - return b.id - a.id; } + return b.id - a.id; }); - } - }); + }); } getPrimaryWorkingMode(model: Model): string {