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

Revert fix for #8729 #8833

Merged
merged 2 commits into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ class VaadinDevmodeGizmo extends LitElement {
const nextReload = lastReload ? (parseInt(lastReload) + 1) : 1;
window.sessionStorage.setItem(VaadinDevmodeGizmo.TRIGGERED_COUNT_KEY_IN_SESSION_STORAGE, nextReload.toString());
window.sessionStorage.setItem(VaadinDevmodeGizmo.TRIGGERED_KEY_IN_SESSION_STORAGE, 'true');
this.reload();
window.location.reload();
}
break;

Expand All @@ -770,48 +770,6 @@ class VaadinDevmodeGizmo extends LitElement {
}
}

reload() {
const iframe = this.shadowRoot.querySelector('#reload-frame');
if (!iframe.contentWindow) {
// if gizmo is detached (an old one from previous page before reload has happened)
// then iframe has no content window anymore
return;
}
iframe.contentWindow.expired = true;
// Set 3 minutes as a timeout for reload
iframe.reloadTimeoutDate = new Date(new Date().getTime() + 3 * 60000);
iframe.contentWindow.location.reload(true);
const transferIframe = function() {
window.document.head.innerHTML = iframe.contentDocument.head.innerHTML;
window.document.body.innerHTML = iframe.contentDocument.body.innerHTML;
};
const checkLoad = function() {
const iframeDoc = iframe.contentDocument;
if (iframeDoc && iframe.contentWindow && iframeDoc.getElementsByTagName('html').length > 0) {
setTimeout(load, 100);
} else {
setTimeout(checkLoad, 100);
}
};
const load = function() {
if (iframe.contentWindow.Vaadin) {
const contentIsPopulated = contentIsPopulated = iframe.contentDocument.body.children.length >= document.body.children.length;
if (contentIsPopulated && !iframe.contentWindow.expired) {
setTimeout(transferIframe, 100);
} else {
setTimeout(load, 100);
}
} else if (new Date() <= iframe.reloadTimeoutDate) {
// After the reload the page content is unexpected: it's not a Vaadin page,
// it might be that the server has not yet restarted. Let's increase the time of the next attempt
setTimeout(checkLoad, 3000);
} else {
delete(iframe.reloadTimeoutDate);
}
};
setTimeout(checkLoad, 0);
}

handleError(msg) {
console.error(msg);
this.status = VaadinDevmodeGizmo.ERROR;
Expand All @@ -829,11 +787,6 @@ class VaadinDevmodeGizmo extends LitElement {
this.disableEventListener = e => this.demoteSplashMessage();
document.body.addEventListener('focus', this.disableEventListener);
document.body.addEventListener('click', this.disableEventListener);
const self = this;
window.onpopstate = function(event) {
const iframe = self.shadowRoot.querySelector('#reload-frame');
iframe.src = window.location.href;
};
this.openWebSocketConnection();

const lastReload = window.sessionStorage.getItem(VaadinDevmodeGizmo.TRIGGERED_KEY_IN_SESSION_STORAGE);
Expand Down Expand Up @@ -1051,8 +1004,7 @@ class VaadinDevmodeGizmo extends LitElement {
? html`<span class="status-description">${this.splashMessage}</span></div>`
: html`<span class="status-description">Live reload ${this.status} </span><span class="ahreflike">Details</span></div>`
}
</div>
<iframe style='display: none;' width='0px' height='0px' src='${window.location.href}' id='reload-frame'></iframe>`;
</div>`;
}
}

Expand Down