fix(editor): 🐛 Throttle incoming typebot to avoid overwrite bug
This commit is contained in:
@ -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)
|
||||
|
@ -92,7 +92,7 @@ const reducer = <T>(state: State<T>, action: Action<T>) => {
|
||||
// )
|
||||
return {
|
||||
past: [...past, present].filter(isDefined),
|
||||
present: newPresent,
|
||||
present: { ...newPresent, updatedAt: new Date() },
|
||||
future: [],
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user