From f987991b24d0e5fe9cfe2a69fbb6d584ab7b6200 Mon Sep 17 00:00:00 2001 From: cstns Date: Tue, 4 Jun 2024 16:59:38 +0300 Subject: [PATCH] Code cleanup --- ui/src/main.mjs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ui/src/main.mjs b/ui/src/main.mjs index fb746dee9..b590da53e 100644 --- a/ui/src/main.mjs +++ b/ui/src/main.mjs @@ -57,11 +57,7 @@ const vuetify = createVuetify({ } }) -/* - * Configure SocketIO Client to Interact with Node-RED - */ - -// if our scoket disconnects, we should inform the user when it reconnects +const host = new URL(window.location.href) function forcePageReload (err) { console.log('auth error:', err) @@ -71,16 +67,15 @@ function forcePageReload (err) { window.location.replace(window.location.origin + '/dashboard' + '?' + 'reloadTime=' + Date.now().toString() + Math.random()) // Seems to work on Edge and Chrome on Windows, Chromium and Firefox on Linux, and also on Chrome Android (and also as PWA App) } -const host = new URL(window.location.href) +/* + * Configure SocketIO Client to Interact with Node-RED + */ + +// if our scoket disconnects, we should inform the user when it reconnects // GET our SocketIO Config from Node-RED & any other bits plugins have added to the _setup endpoint fetch('_setup') .then(async (response) => { - console.log({ - host, - response - }) - switch (true) { case !response.ok && response.status === 401: forcePageReload('Unauthenticated') @@ -91,7 +86,6 @@ fetch('_setup') case host.origin !== new URL(response.url).origin: console.log('Following redirect:', response.url) window.location.replace(response.url) - // forcePageReload('Redirected to different origin') return default: break