chore: import the store directly to update the config
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2021-11-13 17:24:22 +01:00
parent 0609b35c9b
commit 817372b751
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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<void>): Promise<string> => {
const updateConfig = () => store.dispatch('config/update')
export const checkAndSetApiUrl = (url: string): Promise<string> => {
// Check if the url has an http prefix
if (
!url.startsWith('http://') &&

View File

@ -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)
},