Skip to content

Commit

Permalink
pageshow event to check if we got her by history, if so. force reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Moros1138 committed Jul 1, 2024
1 parent 82be504 commit 0e388e9
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions resources/js/app-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,42 @@ const preloader = () =>
});
};

if(!getStorageValue("agreed-to-terms"))
const tryToAgree = async() =>
{
agreeDialog()
.then(() =>
if(!getStorageValue("agreed-to-terms"))
{
try
{
await agreeDialog();
setStorageValue("agreed-to-terms", true);
preloader();
})
.catch(() =>
}
catch(e)
{
removeStorageKey("code");
removeStorageKey("theme");
removeStorageKey("layout");
removeStorageKey("version");
window.location.assign("/disagree");
});
}
else
{
preloader();

window.addEventListener("pageshow", (event) =>
{
let historyTraversal = event.persisted ||( typeof window.performance != "undefined" && window.performance.navigation.type === 2);
if(historyTraversal)
{
// Handle page restore.
window.location.reload();
}
});

const link = document.createElement('a');
link.setAttribute('href', "/disagree")
link.click();
}
}
else
{
preloader();
}
}

tryToAgree();

0 comments on commit 0e388e9

Please sign in to comment.