Skip to content

Commit cbcf166

Browse files
tomoamRich-Harris
andauthored
fix: prevent content from being reset (#309)
Co-authored-by: Rich Harris <[email protected]>
1 parent 293252d commit cbcf166

File tree

2 files changed

+0
-37
lines changed

2 files changed

+0
-37
lines changed

content/tutorial/common/src/__client.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
// Hack into the alert that's used in some tutorials and send a message prior to the alert,
2-
// else the parent thinks we lost contact and wrongfully reloads the page.
3-
// The drawback is that alert is no longer blocking, but no tutorial relies on this.
4-
const alert = window.alert;
5-
window.alert = (message) => {
6-
parent.postMessage(
7-
{
8-
type: 'ping-pause'
9-
},
10-
'*'
11-
);
12-
setTimeout(() => {
13-
alert(message);
14-
});
15-
};
16-
171
window.addEventListener('message', async (e) => {
182
if (e.data.type === 'fetch') {
193
const names = e.data.names;
@@ -121,7 +105,6 @@ function ping() {
121105
);
122106
}
123107

124-
setInterval(ping, 100);
125108
ping();
126109

127110
if (import.meta.hot) {

src/routes/tutorial/[slug]/Output.svelte

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,14 @@
3434
};
3535
});
3636
37-
afterNavigate(() => {
38-
clearTimeout(timeout);
39-
});
40-
41-
/** @type {any} */
42-
let timeout;
43-
4437
/** @param {MessageEvent} e */
4538
async function handle_message(e) {
4639
if (e.origin !== $base) return;
4740
4841
if (paused) return;
4942
5043
if (e.data.type === 'ping') {
51-
path = e.data.data.path ?? path;
5244
loading = false;
53-
54-
clearTimeout(timeout);
55-
timeout = setTimeout(() => {
56-
if (dev && !iframe) return;
57-
58-
// we lost contact, refresh the page
59-
loading = true;
60-
set_iframe_src($base + path);
61-
loading = false;
62-
}, 1000);
63-
} else if (e.data.type === 'ping-pause') {
64-
clearTimeout(timeout);
6545
} else if (e.data.type === 'warnings') {
6646
warnings.update(($warnings) => ({
6747
...$warnings,

0 commit comments

Comments
 (0)