diff --git a/src/components/misc/api-config.vue b/src/components/misc/api-config.vue index af91e408f..4d8eda155 100644 --- a/src/components/misc/api-config.vue +++ b/src/components/misc/api-config.vue @@ -94,7 +94,7 @@ export default { } try { - const url = await checkAndSetApiUrl(this.apiUrl, () => this.$store.dispatch('config/update')) + const url = await checkAndSetApiUrl(this.apiUrl) if (url === '') { // If the config setter function could not figure out a url diff --git a/src/helpers/checkAndSetApiUrl.ts b/src/helpers/checkAndSetApiUrl.ts index 166271c72..d3496568e 100644 --- a/src/helpers/checkAndSetApiUrl.ts +++ b/src/helpers/checkAndSetApiUrl.ts @@ -1,8 +1,12 @@ +import {store} from '@/store' + const API_DEFAULT_PORT = '3456' export const ERROR_NO_API_URL = 'noApiUrlProvided' -export const checkAndSetApiUrl = (url: string, updateConfig: () => Promise): Promise => { +const updateConfig = () => store.dispatch('config/update') + +export const checkAndSetApiUrl = (url: string): Promise => { // Check if the url has an http prefix if ( !url.startsWith('http://') && diff --git a/src/store/index.js b/src/store/index.js index 0580e56b0..250d9c60b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -144,7 +144,7 @@ export const store = createStore({ commit(CURRENT_LIST, currentList) }, async loadApp({commit, dispatch}) { - await checkAndSetApiUrl(window.API_URL, () => dispatch('config/update')) + await checkAndSetApiUrl(window.API_URL) await dispatch('auth/checkAuth') commit('vikunjaReady', true) },