Commit d4cfe2ce authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: reload only when app is sure not losing data

parent fc73422d
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
default_state_json_string = JSON.stringify({ default_state_json_string = JSON.stringify({
panel_visible: false, panel_visible: false,
service_worker_claimed: false, service_worker_claimed: false,
app_reload_requested: false,
setting_id: "setting/" + document.head.querySelector( setting_id: "setting/" + document.head.querySelector(
'script[data-renderjs-configuration="application_title"]' 'script[data-renderjs-configuration="application_title"]'
).textContent, ).textContent,
...@@ -579,7 +580,7 @@ ...@@ -579,7 +580,7 @@
return route(this, 'router', 'redirect', param_list); return route(this, 'router', 'redirect', param_list);
}) })
.allowPublicAcquisition('reload', function reload() { .allowPublicAcquisition('reload', function reload() {
return location.reload(); this.state.app_reload_requested = true;
}) })
.allowPublicAcquisition("getUrlParameter", function getUrlParameter( .allowPublicAcquisition("getUrlParameter", function getUrlParameter(
param_list param_list
...@@ -707,7 +708,8 @@ ...@@ -707,7 +708,8 @@
.allowPublicAcquisition("renderApplication", function renderApplication( .allowPublicAcquisition("renderApplication", function renderApplication(
param_list param_list
) { ) {
if (this.state.service_worker_claimed && if ((this.state.service_worker_claimed ||
this.state.app_reload_requested) &&
(this.state.notification_options === undefined)) { (this.state.notification_options === undefined)) {
// As a new service worker claimed the client, // As a new service worker claimed the client,
// reload the page to ensure it uses the lastest gadget versions // reload the page to ensure it uses the lastest gadget versions
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>994.54001.34070.45704</string> </value> <value> <string>994.65209.11376.49681</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1631797534.82</float> <float>1632469996.87</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment