Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitca0b912

Browse files
authored
preserve URL when resetting (sveltejs#138)
* dont reset path -closessveltejs#118* oops
1 parent1ce6546 commitca0b912

File tree

1 file changed

+34
-39
lines changed

1 file changed

+34
-39
lines changed

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

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,37 @@
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+
115+
selected.set(
116+
/**@type{import('$lib/types').FileStub}*/ (
117+
$files.find((stub)=>stub.name===data.exercise.focus)
118+
)
119+
);
120+
121+
clearTimeout(timeout);
122+
loading=true;
123+
124+
reset_complete_states();
125+
126+
awaitreset_adapter($files);
127+
128+
if (adapter&& path!==data.exercise.path) {
129+
path=data.exercise.path;
130+
set_iframe_src(adapter.base+ path);
131+
}
132+
133+
loading=false;
134+
initial=false;
135+
}catch (e) {
136+
loading=false;
137+
error=/**@type{Error}*/ (e);
138+
console.error(e);
139+
}
140+
});
111141
112142
/**
113143
* Loads the adapter initially or resets it. This method can throw.
@@ -155,40 +185,14 @@
155185
},10000);
156186
});
157187
158-
if (reload_iframe||iframe.src!==adapter.base+data.exercise.path) {
188+
if (reload_iframe) {
159189
awaitnewPromise((fulfil)=>setTimeout(fulfil,200));
160-
set_iframe_src(adapter.base+data.exercise.path);
190+
set_iframe_src(adapter.base+ path);
161191
}
162192
163193
return adapter;
164194
}
165195
166-
asyncfunctionload_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-
awaitreset_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-
192196
/**
193197
*@param{CustomEvent<import('$lib/types').FileStub>}event
194198
*/
@@ -418,16 +422,7 @@
418422
{/if}
419423
420424
{#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-
/>
425+
<Loading {initial} {error} {progress} {status}/>
431426
{/if}
432427
</div>
433428
</section>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp