fix(editor): 🐛 Throttle incoming typebot to avoid overwrite bug
This commit is contained in:
@ -161,13 +161,6 @@ export const TypebotContext = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!typebot || !currentTypebotRef.current) return
|
if (!typebot || !currentTypebotRef.current) return
|
||||||
if (
|
|
||||||
dequal(
|
|
||||||
omit(typebot, 'updatedAt'),
|
|
||||||
omit(currentTypebotRef.current, 'updatedAt')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return
|
|
||||||
if (typebotId !== currentTypebotRef.current.id) {
|
if (typebotId !== currentTypebotRef.current.id) {
|
||||||
setLocalTypebot({ ...typebot })
|
setLocalTypebot({ ...typebot })
|
||||||
flush()
|
flush()
|
||||||
@ -189,10 +182,7 @@ export const TypebotContext = ({
|
|||||||
|
|
||||||
const saveTypebot = async (options?: { disableMutation: boolean }) => {
|
const saveTypebot = async (options?: { disableMutation: boolean }) => {
|
||||||
if (!currentTypebotRef.current || !typebot) return
|
if (!currentTypebotRef.current || !typebot) return
|
||||||
const typebotToSave = {
|
const typebotToSave = { ...currentTypebotRef.current }
|
||||||
...currentTypebotRef.current,
|
|
||||||
updatedAt: new Date().toISOString(),
|
|
||||||
}
|
|
||||||
if (dequal(omit(typebot, 'updatedAt'), omit(typebotToSave, 'updatedAt')))
|
if (dequal(omit(typebot, 'updatedAt'), omit(typebotToSave, 'updatedAt')))
|
||||||
return
|
return
|
||||||
setIsSavingLoading(true)
|
setIsSavingLoading(true)
|
||||||
|
@ -92,7 +92,7 @@ const reducer = <T>(state: State<T>, action: Action<T>) => {
|
|||||||
// )
|
// )
|
||||||
return {
|
return {
|
||||||
past: [...past, present].filter(isDefined),
|
past: [...past, present].filter(isDefined),
|
||||||
present: newPresent,
|
present: { ...newPresent, updatedAt: new Date() },
|
||||||
future: [],
|
future: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user