Store and clear loadConfiguration timeouts
- Avoids double loads if switching servers right after a config load has failed
This commit is contained in:
parent
3cb9f8f315
commit
ca60f2bb09
12
src/App.vue
12
src/App.vue
@ -46,6 +46,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
let loadingTimeout = 0;
|
||||||
|
|
||||||
const store = useStore(),
|
const store = useStore(),
|
||||||
title = computed(() => store.getters.pageTitle),
|
title = computed(() => store.getters.pageTitle),
|
||||||
currentUrl = computed(() => store.getters.url),
|
currentUrl = computed(() => store.getters.url),
|
||||||
@ -61,6 +63,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
loadConfiguration = async () => {
|
loadConfiguration = async () => {
|
||||||
try {
|
try {
|
||||||
|
clearTimeout(loadingTimeout);
|
||||||
showSplash();
|
showSplash();
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
@ -95,7 +98,9 @@ export default defineComponent({
|
|||||||
const error = `Failed to load server configuration for '${store.state.currentServer!.id}'`;
|
const error = `Failed to load server configuration for '${store.state.currentServer!.id}'`;
|
||||||
console.error(`${error}:`, e);
|
console.error(`${error}:`, e);
|
||||||
showSplashError(`${error}\n${e}`, false, ++loadingAttempts.value);
|
showSplashError(`${error}\n${e}`, false, ++loadingAttempts.value);
|
||||||
setTimeout(() => loadConfiguration(), 1000);
|
|
||||||
|
clearTimeout(loadingTimeout);
|
||||||
|
loadingTimeout = setTimeout(() => loadConfiguration(), 1000);
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
@ -184,7 +189,10 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => loadConfiguration());
|
onMounted(() => loadConfiguration());
|
||||||
onBeforeUnmount(() => store.dispatch(ActionTypes.STOP_UPDATES, undefined));
|
onBeforeUnmount(() => {
|
||||||
|
store.dispatch(ActionTypes.STOP_UPDATES, undefined);
|
||||||
|
clearTimeout(loadingTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
handleUrl();
|
handleUrl();
|
||||||
onResize();
|
onResize();
|
||||||
|
Loading…
Reference in New Issue
Block a user