Skip to content

Commit

Permalink
write to js console why we need to reload
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Jul 31, 2023
1 parent 79af0e8 commit ff0081d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nicegui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,23 @@
const messageHandlers = {
connect: () => {
window.socket.emit("handshake", (ok) => {
if (!ok) window.location.reload();
if (!ok) {
console.log('reloading because handshake failed')
window.location.reload();
}
document.getElementById('popup').style.opacity = 0;
});
},
connect_error: (err) => {
if (err.message == 'timeout') window.location.reload(); // see https://github.com/zauberzeug/nicegui/issues/198
if (err.message == 'timeout') {
console.log('reloading because connection time out')
window.location.reload(); // see https://github.com/zauberzeug/nicegui/issues/198
}
},
try_reconnect: () => {
const checkAndReload = async () => {
await fetch(window.location.href, { headers: { 'NiceGUI-Check': 'try_reconnect' } });
console.log('reloading because reconnect was requested')
window.location.reload();
};
setInterval(checkAndReload, 500);
Expand Down

0 comments on commit ff0081d

Please sign in to comment.