Skip to content

Commit

Permalink
fix(copy): imperatively create flows bc side-effect selector out of sync
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-gordon committed Dec 14, 2021
1 parent 6776559 commit b957b5b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/studio-ui/src/web/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ export const pasteFlowNode = (payload: { x: number; y: number }) => async (dispa
// Create new flows for all skills
for (const node of skills) {
let { skillData } = state.flows.flowsByName[node.flow]
skillData = { ...skillData, randomId: nanoid(10) }
const randomId = nanoid(10)
skillData = { ...skillData, randomId }
const { moduleName } = _.find(state.skills.installed, { id: node.skill })
const { data } = await axios.post(
`${window.API_PATH}/studio/modules/${moduleName}/skill/${node.skill}/generateFlow?botId=${window.BOT_ID}&isOneFlow=${window.USE_ONEFLOW}`,
Expand All @@ -217,7 +218,10 @@ export const pasteFlowNode = (payload: { x: number; y: number }) => async (dispa
nodeName: copyName(currentFlowNodeNames, node.name)
})
)
await createNewFlows(getState())
const flows = getState().flows
const flowsByName = flows.flowsByName
const newFlowKey = Object.keys(flowsByName).find(key => flowsByName[key].skillData?.randomId === randomId)
await FlowsAPI.createFlow(flows, newFlowKey)
}

// Paste non-skills
Expand Down

0 comments on commit b957b5b

Please sign in to comment.