Merge branch 'fix/app-ready' into feature/vue3-modals-with-router-4
This commit is contained in:
commit
9a5b5c688d
3 changed files with 5 additions and 9 deletions
|
@ -53,14 +53,14 @@ import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl'
|
||||||
import {useOnline} from '@/composables/useOnline'
|
import {useOnline} from '@/composables/useOnline'
|
||||||
|
|
||||||
import {useRouter, useRoute} from 'vue-router'
|
import {useRouter, useRoute} from 'vue-router'
|
||||||
import {checkAuth} from '@/router'
|
import {getAuthForRoute} from '@/router'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
const ready = computed(() => store.state.vikunjaReady)
|
const ready = ref(false)
|
||||||
const online = useOnline()
|
const online = useOnline()
|
||||||
|
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
|
@ -69,11 +69,11 @@ const showLoading = computed(() => !ready.value && error.value === '')
|
||||||
async function load() {
|
async function load() {
|
||||||
try {
|
try {
|
||||||
await store.dispatch('loadApp')
|
await store.dispatch('loadApp')
|
||||||
const redirectTo = checkAuth(route)
|
const redirectTo = getAuthForRoute(route)
|
||||||
if (typeof redirectTo !== 'undefined') {
|
if (typeof redirectTo !== 'undefined') {
|
||||||
await router.push(redirectTo)
|
await router.push(redirectTo)
|
||||||
}
|
}
|
||||||
store.commit('vikunjaReady', true)
|
ready.value = true
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
error.value = e
|
error.value = e
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,7 +429,7 @@ const router = createRouter({
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
export function checkAuth(route: RouteLocation) {
|
export function getAuthForRoute(route: RouteLocation) {
|
||||||
const authUser = store.getters['auth/authUser']
|
const authUser = store.getters['auth/authUser']
|
||||||
const authLinkShare = store.getters['auth/authLinkShare']
|
const authLinkShare = store.getters['auth/authLinkShare']
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ export const store = createStore({
|
||||||
menuActive: true,
|
menuActive: true,
|
||||||
keyboardShortcutsActive: false,
|
keyboardShortcutsActive: false,
|
||||||
quickActionsActive: false,
|
quickActionsActive: false,
|
||||||
vikunjaReady: false,
|
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
[LOADING](state, loading) {
|
[LOADING](state, loading) {
|
||||||
|
@ -84,9 +83,6 @@ export const store = createStore({
|
||||||
[BACKGROUND](state, background) {
|
[BACKGROUND](state, background) {
|
||||||
state.background = background
|
state.background = background
|
||||||
},
|
},
|
||||||
vikunjaReady(state, ready) {
|
|
||||||
state.vikunjaReady = ready
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async [CURRENT_LIST]({state, commit}, currentList) {
|
async [CURRENT_LIST]({state, commit}, currentList) {
|
||||||
|
|
Loading…
Reference in a new issue