Skip to content
Snippets Groups Projects
Verified Commit 9b98e877 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Fixed API caching not triggered when loading app for first time

parent bf4c1290
No related branches found
No related tags found
No related merge requests found
......@@ -114,7 +114,7 @@ export default {
let defaultInstanceUrl = this.$store.state.instance.frontSettings.defaultServerUrl || process.env.VUE_APP_INSTANCE_URL || this.$store.getters['instance/defaultUrl']()
this.$store.commit('instance/instanceUrl', defaultInstanceUrl)
} else {
// needed to trigger initialization of axios
// needed to trigger initialization of axios / service worker
this.$store.commit('instance/instanceUrl', this.$store.state.instance.instanceUrl)
}
await this.fetchNodeInfo()
......@@ -320,13 +320,6 @@ export default {
'$store.state.instance.instanceUrl' (v) {
this.$store.dispatch('instance/fetchSettings')
this.fetchNodeInfo()
if (this.serviceWorker.registration) {
let sw = this.serviceWorker.registration.active
if (sw) {
sw.postMessage({command: 'serverChosen', serverUrl: v})
}
}
},
'$store.state.ui.theme': {
immediate: true,
......
......@@ -9,6 +9,12 @@ function getDefaultUrl () {
)
}
function notifyServiceWorker (registration, message) {
if (registration && registration.active) {
registration.active.postMessage(message)
}
}
export default {
namespaced: true,
state: {
......@@ -75,7 +81,7 @@ export default {
value = value + '/'
}
state.instanceUrl = value
notifyServiceWorker(state.registration, {command: 'serverChosen', serverUrl: state.instanceUrl})
// append the URL to the list (and remove existing one if needed)
if (value) {
let index = state.knownInstances.indexOf(value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment