🐛 (editor) Fix lost changes when typebot takes a long time to update

Closes #1231
This commit is contained in:
Baptiste Arnaud
2024-02-08 11:03:08 +01:00
parent 5d38b4451a
commit c6489476f9
3 changed files with 134 additions and 133 deletions

View File

@@ -208,7 +208,11 @@ export const TypebotProvider = ({
const saveTypebot = useCallback(
async (updates?: Partial<TypebotV6>) => {
if (!localTypebot || !typebot || isReadOnly) return
const typebotToSave = { ...localTypebot, ...updates }
const typebotToSave = {
...localTypebot,
...updates,
updatedAt: new Date(),
}
if (dequal(omit(typebot, 'updatedAt'), omit(typebotToSave, 'updatedAt')))
return
setLocalTypebot({ ...typebotToSave })