Browse Source

improve reconnect when accessing via On Air

Rodja Trappe 1 year ago
parent
commit
2bfd7f5663
1 changed files with 2 additions and 4 deletions
  1. 2 4
      nicegui/templates/index.html

+ 2 - 4
nicegui/templates/index.html

@@ -272,13 +272,11 @@
                 window.location.reload(); // see https://github.com/zauberzeug/nicegui/issues/198
                 window.location.reload(); // see https://github.com/zauberzeug/nicegui/issues/198
               }
               }
             },
             },
-            try_reconnect: () => {
-              const checkAndReload = async () => {
+            try_reconnect: async () => {
+                document.getElementById('popup').style.opacity = 1;
                 await fetch(window.location.href, { headers: { 'NiceGUI-Check': 'try_reconnect' } });
                 await fetch(window.location.href, { headers: { 'NiceGUI-Check': 'try_reconnect' } });
                 console.log('reloading because reconnect was requested')
                 console.log('reloading because reconnect was requested')
                 window.location.reload();
                 window.location.reload();
-              };
-              setInterval(checkAndReload, 500);
             },
             },
             disconnect: () => {
             disconnect: () => {
               document.getElementById('popup').style.opacity = 1;
               document.getElementById('popup').style.opacity = 1;