2
0

🐛 (js) Improve session remember behavior

Make sure it correctly retrieves saved variables and doesn't clash with other embedded typebots
This commit is contained in:
Baptiste Arnaud
2023-03-02 10:55:03 +01:00
parent c172a44566
commit ba253cf3e9
16 changed files with 122 additions and 42 deletions

View File

@ -89,7 +89,7 @@ test.describe('Builder', () => {
await page.click('text=Save in variables')
await page.click('text=Add an entry >> nth=-1')
await page.click('input[placeholder="Select the data"]')
await page.click('text=data.map(item => item.name)')
await page.click('text=data.flatMap(item => item.name)')
})
})

View File

@ -235,9 +235,12 @@ export const TypebotProvider = ({
)
useEffect(() => {
Router.events.on('routeChangeStart', () => saveTypebot())
const handleSaveTypebot = () => {
saveTypebot()
}
Router.events.on('routeChangeStart', handleSaveTypebot)
return () => {
Router.events.off('routeChangeStart', () => saveTypebot())
Router.events.off('routeChangeStart', handleSaveTypebot)
}
}, [saveTypebot])

View File

@ -88,7 +88,7 @@ export const GeneralSettingsForm = ({
: true
}
onCheckChange={handleNewResultOnRefreshChange}
moreInfoContent="If the user refreshes the page, its existing results will be overwritten. Disable this if you want to create a new results every time the user refreshes the page."
moreInfoContent="If the user refreshes the page or opens the typebot again during the same session, his previous variables will be prefilled and his new answers will override the previous ones."
/>
<SwitchWithLabel
label="Hide query params on bot start"