It makes sense that there is a event which fires whenever the window is opened (including when updating the project). However, I think we also need another event (or a flag which can be read from visionWindowOpened) which will only run when a window is opened with system.nav.openWindow, and not when the project is updated.
The reason this is necessary is because there are actually two kinds of Root Container properties:
- Properties expected to be passed in to system.nav.openWindow
- Internal state properties stored on the Root Container
Usually, internal state properties need to be initialised when the window is opened, to set the window into a clean state.
However, if the project is reloaded, the internal state properties need to be preserved. If we make sure all the important state is stored in root container properties like this (and not within other component properties), the user will not lose their current state when the project is updated.
There are two ways to workaround this, but they are both horrible:
- Create a project function which takes external properties as arguments, does any extra initialisation for internal properties and then passes the whole lot to system.nav.openWindow. This is horrible because window initialisation code is now stored outside of the window.
- Add an additional property to the window to track whether the window has been opened or not. This is horrible because it’s supposed to be an internal property, but it has to be passed to system.nav.openWindow to reset it every time.
Please could we have either another event, or a flag available from visionWindowOpened so we can handle this properly?