How to know which modal is active and with what param(id) v3 &/or v4

#1

I am receiving (socket.io) events to display several modals.
I just want to display 1 modal per id that I receive.

They came like id1, id1, id3, id3, id3, …
I want to have id1, id3 in the stack of modals

So when the user closes id3 will see id1 and when close id1 want se id1 again :slight_smile: .

I was thinking in the home.ts (the root page) call

 let alertModal = this.modalCtrl.create('MyModalPage', { id: myId });
 alertModal.present();

only if active modal (id) != this id

How can I know which modal is active and with what param(id)?

#2

I found this array of modals

this.navCtrl.getViews()[0].data. where data gives me {id: 14, component: ƒ, opts: {…}}

and I can go through the array until navCtrl.getViews().length-1

The problem is this.navCtrl.getViews()[0].dismiss();

Does not dismiss the modal.

But this.navCtrl.getViews()[navCtrl.getViews().length-1].dismiss(); does.

So I only can dismiss the top modal and not the first …