Răsfoiți Sursa

write to js console why we need to reload

Rodja Trappe 1 an în urmă
părinte
comite
ff0081d886
1 a modificat fișierele cu 9 adăugiri și 2 ștergeri
  1. 9 2
      nicegui/templates/index.html

+ 9 - 2
nicegui/templates/index.html

@@ -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);