put only valid project values into store

This commit is contained in:
einhornimmond 2025-03-04 16:31:26 +01:00
parent 024090e362
commit b79ea80da1
3 changed files with 23 additions and 21 deletions

View File

@ -101,7 +101,7 @@ const newUserToSpace = computed(() => form.newUserToSpace)
const logoUrl = computed(() => form.logoUrl) const logoUrl = computed(() => form.logoUrl)
// show space // show space
const getSpace = gql` const getSpace = gql`
query space($id: ID!) { query ($id: ID!) {
space(id: $id) { space(id: $id) {
name name
description description

View File

@ -21,9 +21,9 @@ export class ProjectBrandingResolver {
) )
} }
@Query(() => ProjectBranding, { nullable: true }) @Query(() => ProjectBranding)
@Authorized([RIGHTS.PROJECT_BRANDING_VIEW]) @Authorized([RIGHTS.PROJECT_BRANDING_VIEW])
async projectBranding(@Arg('id', () => Int) id: number): Promise<ProjectBranding | null> { async projectBranding(@Arg('id', () => Int) id: number): Promise<ProjectBranding> {
const projectBrandingEntity = await DbProjectBranding.findOneBy({ id }) const projectBrandingEntity = await DbProjectBranding.findOneBy({ id })
if (!projectBrandingEntity) { if (!projectBrandingEntity) {
throw new LogError(`Project Branding with id: ${id} not found`) throw new LogError(`Project Branding with id: ${id} not found`)

View File

@ -103,8 +103,8 @@
</template> </template>
<script setup> <script setup>
import { onMounted, computed } from 'vue' import { onBeforeMount, computed, watchEffect } from 'vue'
import { useLazyQuery } from '@vue/apollo-composable' import { useQuery } from '@vue/apollo-composable'
import AuthNavbar from '@/components/Auth/AuthNavbar' import AuthNavbar from '@/components/Auth/AuthNavbar'
import AuthNavbarSmall from '@/components/Auth/AuthNavbarSmall' import AuthNavbarSmall from '@/components/Auth/AuthNavbarSmall'
import AuthCarousel from '@/components/Auth/AuthCarousel' import AuthCarousel from '@/components/Auth/AuthCarousel'
@ -115,33 +115,35 @@ import gql from 'graphql-tag'
const communityName = CONFIG.COMMUNITY_NAME const communityName = CONFIG.COMMUNITY_NAME
const store = useStore() const store = useStore()
const projectValue = computed(() => {
const urlParams = new URLSearchParams(window.location.search)
return urlParams.get('project')
})
const setTextSize = (size) => { const setTextSize = (size) => {
document.querySelector('.page-font-size').style.fontSize = size + 'rem' document.querySelector('.page-font-size').style.fontSize = size + 'rem'
} }
const project = computed(() => store.state.project) const { result: projectBannerResult, loading: projectBannerLoading } = useQuery(
const {
result: projectBannerResult,
loading: projectBannerLoading,
load,
} = useLazyQuery(
gql` gql`
query ($project: String!) { query ($project: String!) {
projectBrandingBanner(alias: $project) projectBrandingBanner(alias: $project)
} }
`, `,
{ project }, {
project: projectValue.value,
},
{ enabled: !!projectValue.value },
) )
onMounted(async () => {
const urlParams = new URLSearchParams(window.location.search) onBeforeMount(() => {
const projectValue = urlParams.get('project') // clear state
if (projectValue) { store.commit('project', null)
load() })
store.commit('project', projectValue)
} else { watchEffect(() => {
store.commit('project', '') if (projectBannerResult.value?.projectBrandingBanner) {
store.commit('project', projectValue.value)
} }
}) })
</script> </script>