Purpose: To trigger a dialog on page load only if it hasn't already been opened. The dialog component is separate from the current page.
Issue: The dialog is opening twice.
I attempted to troubleshoot by referencing StackOverflow articles like Angular Material | Check if dialog is open, but they mention using MatDialogRef?
Typescript Code:
ngOnInit()
{
// Reset InActiveV to false in case of page refresh to ensure chat calls StartPVQueue
sessionStorage.setItem('InActiveV', "false");
// Initiate visit on API and retrieve medical information
const starting = timer(500, 10000);
this.startVSubscription = starting.subscribe(val =>{
if (!this.isLoad) {
this.PStartV();
//this.cmdOpenDialog_OnInit();
}
else {
this.startVSubscription.unsubscribe();
}
});
this.cmdOpenDialog_OnInit();
}
cmdOpenDialog_OnInit() {
if (!this.dialog) {
return;
}
this.dialog.open(DialogInternalNotesThreeComponent, {
data: {
data: this.internalNotes
}
});
}