2
0

fix(editor): 🐛 Throttle incoming typebot to avoid overwrite bug

This commit is contained in:
Baptiste Arnaud
2022-05-12 10:04:19 -07:00
parent 22e4873c11
commit 6af47f0277
2 changed files with 2 additions and 12 deletions

View File

@ -161,13 +161,6 @@ export const TypebotContext = ({
useEffect(() => {
if (!typebot || !currentTypebotRef.current) return
if (
dequal(
omit(typebot, 'updatedAt'),
omit(currentTypebotRef.current, 'updatedAt')
)
)
return
if (typebotId !== currentTypebotRef.current.id) {
setLocalTypebot({ ...typebot })
flush()
@ -189,10 +182,7 @@ export const TypebotContext = ({
const saveTypebot = async (options?: { disableMutation: boolean }) => {
if (!currentTypebotRef.current || !typebot) return
const typebotToSave = {
...currentTypebotRef.current,
updatedAt: new Date().toISOString(),
}
const typebotToSave = { ...currentTypebotRef.current }
if (dequal(omit(typebot, 'updatedAt'), omit(typebotToSave, 'updatedAt')))
return
setIsSavingLoading(true)