From e71915cbbaa19bfe27dcef62e6852bdc153c699b Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Thu, 13 Feb 2025 15:37:36 -0500 Subject: [PATCH] Fix loading of page when accessing pages directly --- frontend/src/stores/brandingStore.js | 40 ++++++++----------- frontend/src/views/creators/BannerActions.vue | 26 +++--------- frontend/src/views/creators/CreatorLayout.vue | 11 ++++- 3 files changed, 32 insertions(+), 45 deletions(-) diff --git a/frontend/src/stores/brandingStore.js b/frontend/src/stores/brandingStore.js index 7f51705..eecbee3 100644 --- a/frontend/src/stores/brandingStore.js +++ b/frontend/src/stores/brandingStore.js @@ -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 } }) diff --git a/frontend/src/views/creators/BannerActions.vue b/frontend/src/views/creators/BannerActions.vue index 62c99de..f188be6 100644 --- a/frontend/src/views/creators/BannerActions.vue +++ b/frontend/src/views/creators/BannerActions.vue @@ -1,8 +1,7 @@