🐛 (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:
@ -1,16 +1,19 @@
|
||||
const sessionStorageKey = 'resultId'
|
||||
|
||||
export const getExistingResultIdFromSession = () => {
|
||||
export const getExistingResultIdFromSession = (typebotId?: string) => {
|
||||
if (!typebotId) return
|
||||
try {
|
||||
return sessionStorage.getItem(sessionStorageKey) ?? undefined
|
||||
return (
|
||||
sessionStorage.getItem(`${sessionStorageKey}-${typebotId}`) ?? undefined
|
||||
)
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
}
|
||||
|
||||
export const setResultInSession = (resultId: string) => {
|
||||
export const setResultInSession = (typebotId: string, resultId: string) => {
|
||||
try {
|
||||
return sessionStorage.setItem(sessionStorageKey, resultId)
|
||||
return sessionStorage.setItem(`${sessionStorageKey}-${typebotId}`, resultId)
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
|
Reference in New Issue
Block a user