diff --git a/packages/cli/src/assets/autoreload.js b/packages/cli/src/assets/autoreload.js index 3d7d40012..51ca89514 100644 --- a/packages/cli/src/assets/autoreload.js +++ b/packages/cli/src/assets/autoreload.js @@ -2,29 +2,33 @@ // https://github.com/DioxusLabs/dioxus/tree/master/packages/cli (function () { - var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - var url = protocol + '//' + window.location.host + '/_dioxus/ws'; - var poll_interval = 8080; + var protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; + var url = protocol + "//" + window.location.host + "/_dioxus/ws"; + var poll_interval = 8080; - var reload_upon_connect = () => { - window.setTimeout( - () => { - var ws = new WebSocket(url); - ws.onopen = () => window.location.reload(); - ws.onclose = reload_upon_connect; - }, - poll_interval); + var reload_upon_connect = (event) => { + // Firefox will send a 1001 code when the connection is closed because the page is reloaded + // Only firefox will trigger the onclose event when the page is reloaded manually: https://stackoverflow.com/questions/10965720/should-websocket-onclose-be-triggered-by-user-navigation-or-refresh + // We should not reload the page in this case + if (event.code === 1001) { + return; + } + window.setTimeout(() => { + var ws = new WebSocket(url); + ws.onopen = () => window.location.reload(); + ws.onclose = reload_upon_connect; + }, poll_interval); }; - var ws = new WebSocket(url); + var ws = new WebSocket(url); - ws.onmessage = (ev) => { - console.log("Received message: ", ev, ev.data); + ws.onmessage = (ev) => { + console.log("Received message: ", ev, ev.data); - if (ev.data == "reload") { - window.location.reload(); - } + if (ev.data == "reload") { + window.location.reload(); + } }; ws.onclose = reload_upon_connect; -})() +})(); diff --git a/packages/fullstack/dist/index.html b/packages/fullstack/dist/index.html deleted file mode 100644 index f7830275d..000000000 --- a/packages/fullstack/dist/index.html +++ /dev/null @@ -1,47 +0,0 @@ - - -
-