Skip to content

Commit 3942c57

Browse files
committed
dont reset path - closes #118
1 parent 491f150 commit 3942c57

File tree

1 file changed

+30
-39
lines changed

1 file changed

+30
-39
lines changed

src/routes/tutorial/[slug]/+page.svelte

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,33 @@
107107
return destroy;
108108
});
109109
110-
afterNavigate(load_exercise);
110+
afterNavigate(async () => {
111+
try {
112+
$files = Object.values(data.exercise.a);
113+
$scope = data.exercise.scope;
114+
path = data.exercise.path;
115+
116+
selected.set(
117+
/** @type {import('$lib/types').FileStub} */ (
118+
$files.find((stub) => stub.name === data.exercise.focus)
119+
)
120+
);
121+
122+
clearTimeout(timeout);
123+
loading = true;
124+
125+
reset_complete_states();
126+
127+
await reset_adapter($files);
128+
129+
loading = false;
130+
initial = false;
131+
} catch (e) {
132+
loading = false;
133+
error = /** @type {Error} */ (e);
134+
console.error(e);
135+
}
136+
});
111137
112138
/**
113139
* Loads the adapter initially or resets it. This method can throw.
@@ -155,40 +181,14 @@
155181
}, 10000);
156182
});
157183
158-
if (reload_iframe || iframe.src !== adapter.base + data.exercise.path) {
184+
if (reload_iframe || iframe.src !== adapter.base + path) {
159185
await new Promise((fulfil) => setTimeout(fulfil, 200));
160-
set_iframe_src(adapter.base + data.exercise.path);
186+
set_iframe_src(adapter.base + path);
161187
}
162188
163189
return adapter;
164190
}
165191
166-
async function load_exercise() {
167-
try {
168-
$files = Object.values(data.exercise.a);
169-
$scope = data.exercise.scope;
170-
selected.set(
171-
/** @type {import('$lib/types').FileStub} */ (
172-
$files.find((stub) => stub.name === data.exercise.focus)
173-
)
174-
);
175-
176-
clearTimeout(timeout);
177-
loading = true;
178-
179-
reset_complete_states();
180-
181-
await reset_adapter($files);
182-
183-
loading = false;
184-
initial = false;
185-
} catch (e) {
186-
loading = false;
187-
error = /** @type {Error} */ (e);
188-
console.error(e);
189-
}
190-
}
191-
192192
/**
193193
* @param {CustomEvent<import('$lib/types').FileStub>} event
194194
*/
@@ -418,16 +418,7 @@
418418
{/if}
419419
420420
{#if loading || error}
421-
<Loading
422-
{initial}
423-
{error}
424-
{progress}
425-
{status}
426-
on:reload={async () => {
427-
error = null;
428-
load_exercise();
429-
}}
430-
/>
421+
<Loading {initial} {error} {progress} {status} />
431422
{/if}
432423
</div>
433424
</section>

0 commit comments

Comments
 (0)