Skip to content

Commit

Permalink
VIH-11119 remove OnChanges lifecycle hook and optimize change detecti…
Browse files Browse the repository at this point in the history
…on (#1448)
  • Loading branch information
shaed-parkar authored Nov 20, 2024
1 parent 7987f82 commit bedf8dc
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core';
import { ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { Subject, takeUntil } from 'rxjs';
import { AvailableLanguageResponse, InterprepretationType } from 'src/app/services/clients/api-client';
Expand All @@ -9,13 +9,13 @@ import { InterpreterSelectedDto } from './interpreter-selected.model';
selector: 'app-interpreter-form',
templateUrl: './interpreter-form.component.html'
})
export class InterpreterFormComponent implements OnInit, OnDestroy, OnChanges {
export class InterpreterFormComponent implements OnInit, OnDestroy {
forceDisplayForm: boolean;

@Input() set requireLanguageSelection(forceSelection: boolean) {
this.forceDisplayForm = forceSelection;
this.displayForm = forceSelection;
this.cdRef.detectChanges();
this.cdRef.markForCheck();
}

@Output() interpreterLanguageSelected = new EventEmitter<InterpreterSelectedDto>();
Expand All @@ -36,12 +36,6 @@ export class InterpreterFormComponent implements OnInit, OnDestroy, OnChanges {
this.createForm();
}

ngOnChanges(changes: SimpleChanges): void {
if (changes.requireLanguageSelection) {
this.forceValidation();
}
}

get availableSignLanguages(): AvailableLanguageResponse[] {
return this.availableLanguages.filter(l => l.type === InterprepretationType.Sign);
}
Expand Down

0 comments on commit bedf8dc

Please sign in to comment.