hlxsites / zemax

AEM Franklin Solution for https://www.zemax.com/
https://main--zemax--hlxsites.hlx.page/
Apache License 2.0
3 stars 1 forks source link

Concurrency issues on profile page #180

Closed shehjadkhan-ansys closed 1 year ago

shehjadkhan-ansys commented 1 year ago

This PR https://github.com/hlxsites/zemax/pull/172 introduced a bug

To reproduce

  1. Logout then login this bug is shown only first on first load as localstorage item for webroles is not created, reloading the profile page loads the page properly.

Further context webroles.js line 30 localStorage.setItem('webroles', JSON.stringify(webroles)); these webroles are read in user-tickets.js Line 10 const webroles = JSON.parse(localStorage.getItem('webroles'));

shehjadkhan-ansys commented 1 year ago

Not sure what is the best approach to handle these cases, in this case we can make one more call to webrole API and remove the dependency on localstorage, but in general how should we handle such dependency as we have lot of features on profile page which are permission dependent for example on profile page if the user is license administrator they see manage button while other users see View button only and so on.

synox commented 1 year ago

I don't have all the context here. Generally, you could have a central function with initializes the data and stores a Promise on the global window object (or just as a variable in the JS module). Other code can then await or .then() when the data is ready.

shehjadkhan-ansys commented 1 year ago

https://github.com/hlxsites/zemax/pull/191 Should fix above issue, in above PR I am have added event listeners on the localstorage element and thus we would be able to render code currently but still update the view when results are back