Commit b175dc91 authored by Boris Kocherov's avatar Boris Kocherov

erp5_officejs: reconnect to serviceworker if window.url is changed

the bug corrected by this commit took place if: the url is changed while Service Worker is stopped (that happens when Devtool is closed and  no any events were for Sevice Worker during sometime (about 1 min))
parent b4f1b704
......@@ -182,7 +182,8 @@
subhash,
keyvalue,
index,
args = {};
args = {},
queue = new RSVP.Queue();
if (hash !== undefined) {
subhashes = hash.split('&');
for (index in subhashes) {
......@@ -198,10 +199,34 @@
}
}
return gadget.renderApplication({
args: args
if ('serviceWorker' in navigator) {
// importatant register service worker
// for client reconnect if url change
queue.push(function () {
return RSVP.Promise(function (resolve, reject) {
navigator.serviceWorker.ready
.then(function (swr) {
return swr.active.scriptURL;
})
.then(function (scriptURL) {
return navigator.serviceWorker.register(scriptURL);
})
.then(navigator.serviceWorker.ready)
.then(function (reg) {
resolve(reg);
})
.then(undefined, function (error) {
reject(error);
});
});
});
}
queue.push(function () {
return gadget.renderApplication({
args: args
});
});
return queue;
}
var result = loopEventListener(window, 'hashchange', false,
......@@ -395,4 +420,4 @@
});
});
}(window, rJS));
}(window, rJS));
\ No newline at end of file
......@@ -224,7 +224,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.57938.10343.57463</string> </value>
<value> <string>955.19276.22837.65433</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -242,7 +242,7 @@
</tuple>
<state>
<tuple>
<float>1478077191.73</float>
<float>1479212571.34</float>
<string>UTC</string>
</tuple>
</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