Skip to content

Commit

Permalink
fix: replace if statement with rxjs filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
romeonicholas committed Nov 28, 2023
1 parent 6adf6cc commit 4222674
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4222674

Please sign in to comment.