Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cstns committed Jun 4, 2024
1 parent 753bb41 commit f987991
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions ui/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit f987991

Please sign in to comment.