feat: centeralize the start ingestion logic in host app store

This commit is contained in:
oguzhankoral
2026-01-27 12:45:41 +03:00
parent d788c79b36
commit 58c0b74bcc
2 changed files with 15 additions and 17 deletions
+4 -16
View File
@@ -135,12 +135,9 @@ import {
canCreateVersionQuery,
setVersionMessageMutation
} from '~/lib/graphql/mutationsAndQueries'
import { useModelIngestion } from '~/lib/ingestion/composables/useModelIngestion'
const store = useHostAppStore()
const accountStore = useAccountStore()
const { startIngestion } = useModelIngestion()
const { trackEvent } = useMixpanel()
const app = useNuxtApp()
@@ -173,16 +170,7 @@ const canCreateVersion = computed(() => {
return canCreateVersionResult.value?.project.model.permissions.canCreateVersion
})
const sendViaIngestion = async (actionSource: string) => {
const sourceData = {
sourceApplicationSlug: store.hostAppName || 'unknown',
sourceApplicationVersion: store.hostAppVersion?.toString() || 'unknown'
}
await startIngestion(props.modelCard, 'Starting to publish', sourceData)
store.sendModel(props.modelCard.modelCardId, actionSource)
}
const sendOrCancel = async () => {
const sendOrCancel = () => {
if (!props.canEdit) {
return
}
@@ -190,7 +178,7 @@ const sendOrCancel = async () => {
store.sendModelCancel(props.modelCard.modelCardId)
// TODO: cancel ingestion
} else {
await sendViaIngestion('ModelCardButton')
store.sendModel(props.modelCard.modelCardId, 'ModelCardButton')
}
hasSetVersionMessage.value = false
}
@@ -266,7 +254,7 @@ const setVersionMessage = async (message: string) => {
const saveFilterAndSend = async () => {
await saveFilter()
await sendViaIngestion('Filter')
store.sendModel(props.modelCard.modelCardId, 'Filter')
hasSetVersionMessage.value = false
}
@@ -312,7 +300,7 @@ const expiredNotification = computed(() => {
if (props.modelCard.progress) {
await store.sendModelCancel(props.modelCard.modelCardId)
}
await sendViaIngestion(ctaType)
store.sendModel(props.modelCard.modelCardId, ctaType)
},
disabled: !canCreateVersion.value?.authorized,
tooltipText: canCreateVersion.value?.authorized
+11 -1
View File
@@ -44,7 +44,7 @@ export const useHostAppStore = defineStore('hostAppStore', () => {
const { $openUrl } = useNuxtApp()
const accountsStore = useAccountStore()
const { checkUpdate } = useUpdateConnector()
const { updateIngestion } = useModelIngestion()
const { startIngestion, updateIngestion } = useModelIngestion()
const isDistributedBySpeckle = ref<boolean>(true)
const latestAvailableVersion = ref<Version | null>(null)
@@ -140,6 +140,7 @@ export const useHostAppStore = defineStore('hostAppStore', () => {
const addModel = async (model: IModelCard) => {
await app.$baseBinding.addModel(model)
documentModelStore.value.models.push(model)
console.log(documentModelStore)
}
/**
@@ -356,6 +357,15 @@ export const useHostAppStore = defineStore('hostAppStore', () => {
model.progress = { status: 'Starting to send...' }
model.expired = false
model.report = undefined
// TODO: we need to handle it conditionally for the sake of old connectors
// model ingestion
const sourceData = {
sourceApplicationSlug: hostAppName.value || 'unknown',
sourceApplicationVersion: hostAppVersion.value?.toString() || 'unknown'
}
void startIngestion(model, 'Starting to publish', sourceData)
// You should stop asking why if you saw anything related autocad..
// It solves the press "escape" issue.
// Because probably we don't give enough time to acad complete it's previos task and it stucks.