handle gateway connecting before page load

This commit is contained in:
hippoz 2023-01-03 23:25:57 +02:00
parent 67f1b481ac
commit fa6f65ce8a
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

@ -12,9 +12,22 @@ import { timeline } from './timeline';
timeline.start();
let loaded = false;
let loadedListener = null;
document.addEventListener("DOMContentLoaded", () => {
loaded = true;
if (loadedListener) {
loadedListener();
loadedListener = null;
}
});
function handleGatewaySettlement() {
timeline.addCheckpoint("Got gateway settlement");
const loadApplication = () => {
timeline.addCheckpoint("Application load started");
const loadingElement = document.getElementById("pre--loading-screen");
if (loadingElement) {
loadingElement.parentElement.removeChild(loadingElement);
@ -47,6 +60,15 @@ function handleGatewaySettlement() {
timeline.addCheckpoint("All initialization finished");
timeline.dump();
};
if (!loaded) {
timeline.addCheckpoint("Waiting for DOM content before loading application");
loadedListener = loadApplication;
} else {
loadApplication();
}
}
function main() {