Incognito mode local storage issue (#33)

This commit is contained in:
Chirag 2022-11-28 21:41:04 +05:30 committed by GitHub
parent 4027a6fe18
commit 91d18422de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -192,7 +192,9 @@ export default {
form_id: this.form.id form_id: this.form.id
}) })
window.localStorage.removeItem(this.form.form_pending_submission_Key) try {
window.localStorage.removeItem(this.form.form_pending_submission_key)
} catch (e) {}
if (response.data.redirect && response.data.redirect_url) { if (response.data.redirect && response.data.redirect_url) {
window.location.href = response.data.redirect_url window.location.href = response.data.redirect_url

View File

@ -222,7 +222,9 @@ export default {
deep: true, deep: true,
handler () { handler () {
if(this.isPublicFormPage && this.form && this.dataFormValue){ if(this.isPublicFormPage && this.form && this.dataFormValue){
window.localStorage.setItem(this.form.form_pending_submission_Key, JSON.stringify(this.dataFormValue)) try {
window.localStorage.setItem(this.form.form_pending_submission_key, JSON.stringify(this.dataFormValue))
} catch (e) {}
} }
} }
}, },
@ -275,7 +277,12 @@ export default {
}, },
initForm () { initForm () {
if (this.isPublicFormPage) { if (this.isPublicFormPage) {
const pendingData = window.localStorage.getItem(this.form.form_pending_submission_Key) let pendingData
try {
pendingData = window.localStorage.getItem(this.form.form_pending_submission_key)
} catch (e) {
pendingData = null
}
if(pendingData !== null && pendingData){ if(pendingData !== null && pendingData){
this.dataForm = new Form(JSON.parse(pendingData)) this.dataForm = new Form(JSON.parse(pendingData))
return return