Files
speckle-server/packages/frontend-2/components/presentation/viewer/Wrapper.vue
T
Kristaps Fabians Geikins d394e1cd9b fix: various presentations mode fixes related to resetting (#5635)
* better workspace feature flag ops

* user activity is correctly tracked

* more fixes
2025-10-03 12:39:59 +03:00

99 lines
2.7 KiB
Vue

<template>
<ViewerStateSetup :init-params="initParams">
<PresentationViewerPostSetup>
<PresentationViewerSetup
@loading-change="onLoadingChange"
@progress-change="onProgressChange"
/>
</PresentationViewerPostSetup>
</ViewerStateSetup>
</template>
<script setup lang="ts">
import { resourceBuilder } from '@speckle/shared/viewer/route'
import { writableAsyncComputed } from '~/lib/common/composables/async'
import { graphql } from '~/lib/common/generated/gql/gql'
import { useInjectedPresentationState } from '~/lib/presentations/composables/setup'
import { ViewerRenderPageType } from '~/lib/viewer/helpers/state'
import type { UseSetupViewerParams } from '~~/lib/viewer/composables/setup'
/**
* Don't put much logic here, the viewer state is unavailable here so do as much as u can in PresentationViewerSetup instead
*/
graphql(`
fragment PresentationViewerPageWrapper_SavedViewGroup on SavedViewGroup {
id
views(input: $input) {
totalCount
items {
id
resourceIdString
}
}
}
`)
const {
projectId,
viewer: { resourceIdString: coreResourceIdString },
ui: { slide }
} = useInjectedPresentationState()
const route = useRoute()
// Resolved from the presentation's views, but also has to be at least somewhat mutable
// cause some viewer internals try to change it
const resourceIdString = writableAsyncComputed({
get: () => coreResourceIdString.value,
set: async (newVal) => {
const newResources = resourceBuilder().addResources(newVal).toString()
const currentResources = coreResourceIdString.value
if (newResources === currentResources) return
// we don't want this to happen, so lets log it
// to see the cause and make it not do that
devTrace('Unexpected resourceIdString mutation', {
newVal: newResources,
oldVal: currentResources
})
},
initialState: route.params.modelId as string,
asyncRead: false
})
const savedViewId = computed({
get: () => slide.value?.id || null,
set: (newVal) => {
// we don't want this to happen, so lets log it
// to see the cause and make it not do that
devTrace('Unexpected savedViewId mutation', { newVal, oldVal: slide.value?.id })
}
})
const loadOriginal = ref(false)
const emit = defineEmits<{
(e: 'loading-change', loading: boolean): void
(e: 'progress-change', progress: number): void
}>()
const onLoadingChange = (loading: boolean) => {
emit('loading-change', loading)
}
const onProgressChange = (progress: number) => {
emit('progress-change', progress)
}
const initParams = computed(
(): UseSetupViewerParams => ({
projectId,
resourceIdString,
pageType: ViewerRenderPageType.Presentation,
savedView: {
id: savedViewId,
loadOriginal
}
})
)
</script>