Skip to content

Commit

Permalink
dont reload on navigation event. Closes #3045 (#3051)
Browse files Browse the repository at this point in the history
  • Loading branch information
cscheid authored Oct 26, 2022
1 parent f19b898 commit 85c9e30
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/resources/editor/devserver/devserver-core.html
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,20 @@ <h2 class="modal__title" id="quarto-log-error-modal-title">
let path = window.location.pathname;
if (!/\/$/.test(path)) path += "/";
const devServerSocket = new WebSocket(protocol + "//" + window.location.host + path);
let reloadPage = true;
addEventListener("beforeunload", () => {
// don't reload page in case of navigation events
reloadPage = false;
})
devServerSocket.onopen = () => {
console.log('Socket connection open. Listening for events.');
// if the socket closes for any reason (e.g. this occurs in electron apps
// when the computer suspends) then reload to reestablish the connection
devServerSocket.onclose = () => {
console.log('Socket connection closed. Reloading.');
window.location.reload(true);
if (reloadPage) {
console.log('Socket connection closed. Reloading.');
window.location.reload(true);
}
}
};
// append for errors that occur within the error window
Expand Down

0 comments on commit 85c9e30

Please sign in to comment.