Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pageshow event to check if we got her by history, if so. force reload #115

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();