| 456 | // check if chatflow has changed before saving |
| 457 | useEffect(() => { |
| 458 | const checkIfHasChanged = async () => { |
| 459 | if (getHasChatflowChangedApi.data?.hasChanged === true) { |
| 460 | const confirmPayload = { |
| 461 | title: `Confirm Change`, |
| 462 | description: `${canvasTitle} ${chatflow.name} has changed since you have opened, overwrite changes?`, |
| 463 | confirmButtonName: 'Confirm', |
| 464 | cancelButtonName: 'Cancel' |
| 465 | } |
| 466 | const isConfirmed = await confirm(confirmPayload) |
| 467 | |
| 468 | if (!isConfirmed) { |
| 469 | return |
| 470 | } |
| 471 | } |
| 472 | const updateBody = { |
| 473 | name: chatflowName, |
| 474 | flowData |
| 475 | } |
| 476 | updateChatflowApi.request(chatflow.id, updateBody) |
| 477 | } |
| 478 | |
| 479 | if (getHasChatflowChangedApi.data) { |
| 480 | checkIfHasChanged() |