Skip to content

Commit c34a754

Browse files
author
Rich Harris
committed
Merge branch 'main' of github.com:sveltejs/learn.svelte.dev
2 parents 517ae81 + cbcf166 commit c34a754

File tree

7 files changed

+5
-42
lines changed

7 files changed

+5
-42
lines changed

content/tutorial/01-svelte/08-stores/02-auto-subscriptions/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Start by declaring `unsubscribe` in `App.svelte`:
1515

1616
> Calling a `subscribe` method returns an `unsubscribe` function.
1717
18-
You now declared `unsubscribe`, but it still needs to be called, for example through the `onDestroy` [lifecycle hook](/tutorial/ondestroy):
18+
You now declared `unsubscribe`, but it still needs to be called, for example through the `onDestroy` lifecycle hook:
1919

2020
```svelte
2121
/// file: App.svelte

content/tutorial/04-advanced-sveltekit/03-advanced-routing/04-route-groups/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { redirect } from '@sveltejs/kit';
1616

1717
export function load({ cookies, url }) {
1818
if (!cookies.get('logged_in')) {
19-
throw redirect(307, `/login?redirectTo=${url.pathname}`);
19+
throw redirect(303, `/login?redirectTo=${url.pathname}`);
2020
}
2121
}
2222
```

content/tutorial/04-advanced-sveltekit/03-advanced-routing/04-route-groups/app-a/src/routes/login/+page.server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { redirect } from '@sveltejs/kit';
33
export const actions = {
44
default: ({ cookies, url }) => {
55
cookies.set('logged_in', 'true', { path: '/' });
6-
throw redirect(307, url.searchParams.get('redirectTo') ?? '/');
6+
throw redirect(303, url.searchParams.get('redirectTo') ?? '/');
77
}
88
};

content/tutorial/04-advanced-sveltekit/03-advanced-routing/04-route-groups/app-a/src/routes/logout/+page.server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { redirect } from '@sveltejs/kit';
33
export const actions = {
44
default: ({ cookies }) => {
55
cookies.delete('logged_in', { path: '/' });
6-
throw redirect(307, '/');
6+
throw redirect(303, '/');
77
}
88
};

content/tutorial/04-advanced-sveltekit/03-advanced-routing/04-route-groups/app-b/src/routes/(authed)/+layout.server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { redirect } from '@sveltejs/kit';
22

33
export function load({ cookies, url }) {
44
if (!cookies.get('logged_in')) {
5-
throw redirect(307, `/login?redirectTo=${url.pathname}`);
5+
throw redirect(303, `/login?redirectTo=${url.pathname}`);
66
}
77
}

content/tutorial/common/src/__client.js

-17
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

-20
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)