⚡️ Reset remembered state if the typebot is updated (#1675)
Wipe stored chat state if a typebot is updated. Resolves #1508 Resolves #1427 https://github.com/user-attachments/assets/7668d6a7-2916-4158-b715-1cccaeaf6ddf --------- Co-authored-by: Baptiste Arnaud <baptiste.arnaud95@gmail.com>
This commit is contained in:
@@ -150,8 +150,25 @@ export const Bot = (props: BotProps & { class?: string }) => {
|
||||
const initialChatInStorage = getInitialChatReplyFromStorage(
|
||||
data.typebot.id
|
||||
)
|
||||
if (initialChatInStorage) {
|
||||
setInitialChatReply(initialChatInStorage)
|
||||
if (
|
||||
initialChatInStorage &&
|
||||
initialChatInStorage.typebot.publishedAt &&
|
||||
data.typebot.publishedAt
|
||||
) {
|
||||
if (
|
||||
new Date(initialChatInStorage.typebot.publishedAt).getTime() ===
|
||||
new Date(data.typebot.publishedAt).getTime()
|
||||
) {
|
||||
setInitialChatReply(initialChatInStorage)
|
||||
} else {
|
||||
// Restart chat by resetting remembered state
|
||||
wipeExistingChatStateInStorage(data.typebot.id)
|
||||
setInitialChatReply(data)
|
||||
setInitialChatReplyInStorage(data, {
|
||||
typebotId: data.typebot.id,
|
||||
storage,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
setInitialChatReply(data)
|
||||
setInitialChatReplyInStorage(data, {
|
||||
|
||||
Reference in New Issue
Block a user