Переглянути джерело

Merge pull request #2147 from zauberzeug/on-air-reconnect

Improve reconnect when accessing via On Air
Falko Schindler 1 рік тому
батько
коміт
496b282620
1 змінених файлів з 5 додано та 7 видалено
  1. 5 7
      nicegui/templates/index.html

+ 5 - 7
nicegui/templates/index.html

@@ -272,13 +272,11 @@
                 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);
+            try_reconnect: async () => {
+              document.getElementById('popup').style.opacity = 1;
+              await fetch(window.location.href, { headers: { 'NiceGUI-Check': 'try_reconnect' } });
+              console.log('reloading because reconnect was requested')
+              window.location.reload();
             },
             disconnect: () => {
               document.getElementById('popup').style.opacity = 1;