Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure app reloads without using cache #1462

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 29 additions & 21 deletions ui/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -275,31 +275,39 @@ fetch('_setup')
location.reload()
}

// loads minimal VueJS app to display error message and options to user
function loadFallback (error) {
// pass the error to the Vuex store
store.commit('setup/setError', error)
const app = Vue.createApp(App)
.use(store)
.use(vuetify)
.use(router)

const head = createHead()
app.use(head)
app.mixin(VueHeadMixin)

// mount the VueJS app into <div id="app"></div> in /ui/public/index.html
app.mount('#app')
}

let error = {}
if (navigator.onLine) {
error = { error: err, type: 'server unreachable', message: 'There was an error loading the Dashboard.' }
// Add timer to reload the page every 20 seconds
setInterval(() => {
location.reload()
}, 20000)
if (err instanceof TypeError && err.message === 'Failed to fetch') {
forcePageReload(err)
} else {
error = { error: err, type: 'server unreachable', message: 'There was an error loading the Dashboard.' }
loadFallback(error)
// Add timer to reload the page every 20 seconds
setInterval(() => {
location.reload()
}, 20000)
}
} else {
error = { error: err, type: 'no internet', message: 'Your device appears to be offline.' }
// Add event listener
window.addEventListener('online', handleOnline)
error = { error: err, type: 'no internet', message: 'Your device appears to be offline.' }
loadFallback(error)
}

store.commit('setup/setError', error) // pass the error to the Vuex store

// load minimal VueJS app to display error message and options to user
const app = Vue.createApp(App)
.use(store)
.use(vuetify)
.use(router)

const head = createHead()
app.use(head)
app.mixin(VueHeadMixin)

// mount the VueJS app into <div id="app"></div> in /ui/public/index.html
app.mount('#app')
})
Loading