Fix loading of page when accessing pages directly
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {useClient} from "@/plugins/api.js";
|
||||
import {useSessionStorage} from "@vueuse/core";
|
||||
import {ref, watch} from "vue";
|
||||
import {useRoute} from "vue-router";
|
||||
import {ref} from "vue";
|
||||
|
||||
export const useBrandingStore = defineStore(
|
||||
'branding',
|
||||
@@ -16,29 +15,25 @@ export const useBrandingStore = defineStore(
|
||||
{},
|
||||
{writeDefaults: false})
|
||||
|
||||
const presentationInfos = ref([])
|
||||
const presentationInfos = ref([])
|
||||
|
||||
const route = useRoute()
|
||||
watch(
|
||||
() => route.params.creator,
|
||||
async (newCreator, oldCreator) => {
|
||||
loading.value = true
|
||||
async function updateBrand(newBrand) {
|
||||
loading.value = true
|
||||
|
||||
if (newCreator !== oldCreator) {
|
||||
if (newCreator !== undefined) {
|
||||
value.value = await fetchCreatorData(newCreator)
|
||||
currentBrand.value = newCreator
|
||||
presentationInfos.value = value.value?.presentationInfos
|
||||
} else {
|
||||
value.value = {}
|
||||
currentBrand.value = undefined
|
||||
presentationInfos.value = []
|
||||
}
|
||||
if (newBrand !== currentBrand.value) {
|
||||
if (newBrand !== undefined) {
|
||||
value.value = await fetchCreatorData(newBrand)
|
||||
currentBrand.value = newBrand
|
||||
presentationInfos.value = value.value?.presentationInfos
|
||||
} else {
|
||||
value.value = {}
|
||||
currentBrand.value = undefined
|
||||
presentationInfos.value = []
|
||||
}
|
||||
|
||||
loading.value = false
|
||||
}
|
||||
)
|
||||
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const fetchCreatorData = async (creatorAlias) => {
|
||||
try {
|
||||
@@ -53,7 +48,6 @@ export const useBrandingStore = defineStore(
|
||||
return {
|
||||
currentBrand,
|
||||
value,
|
||||
loading,
|
||||
presentationInfos
|
||||
loading, updateBrand, presentationInfos
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user