Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15750 from ElectronicBlueberry/workflow-editor-lo…
…ading-issue [23.0] Fix Worflow editor loading issues
- Loading branch information
Showing
1 changed file
with
18 additions
and
10 deletions.
There are no files selected for viewing
28 changes: 18 additions & 10 deletions
28
client/src/components/Workflow/Editor/composables/useTerminal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
import type { DatatypesMapperModel } from "@/components/Datatypes/model"; | ||
import { terminalFactory } from "@/components/Workflow/Editor/modules/terminals"; | ||
import type { Step, TerminalSource } from "@/stores/workflowStepStore"; | ||
import { ref, watchEffect, type Ref } from "vue"; | ||
import { ref, watch, type Ref, computed } from "vue"; | ||
import { useWorkflowStepStore } from "@/stores/workflowStepStore"; | ||
|
||
export function useTerminal( | ||
stepId: Ref<Step["id"]>, | ||
terminalSource: Ref<TerminalSource>, | ||
datatypesMapper: Ref<DatatypesMapperModel> | ||
) { | ||
const terminal = ref(); | ||
const isMappedOver = ref(false); | ||
watchEffect(() => { | ||
// rebuild terminal if any of the tracked dependencies change | ||
const newTerminal = terminalFactory(stepId.value, terminalSource.value, datatypesMapper.value); | ||
newTerminal.getInvalidConnectedTerminals(); | ||
terminal.value = newTerminal; | ||
isMappedOver.value = newTerminal.isMappedOver(); | ||
}); | ||
const terminal: Ref<ReturnType<typeof terminalFactory> | null> = ref(null); | ||
const stepStore = useWorkflowStepStore(); | ||
const isMappedOver = computed(() => stepStore.stepMapOver[stepId.value]?.isCollection ?? false); | ||
|
||
watch( | ||
[stepId, terminalSource, datatypesMapper], | ||
() => { | ||
// rebuild terminal if any of the tracked dependencies change | ||
const newTerminal = terminalFactory(stepId.value, terminalSource.value, datatypesMapper.value); | ||
newTerminal.getInvalidConnectedTerminals(); | ||
terminal.value = newTerminal; | ||
}, | ||
{ | ||
immediate: true, | ||
} | ||
); | ||
return { terminal: terminal as Ref<ReturnType<typeof terminalFactory>>, isMappedOver }; | ||
} |