Skip to content

Commit 36be474

Browse files
committed
Always clear adress bar from ?s=...
1 parent edd84c2 commit 36be474

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

apps/class-solid/src/lib/state.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ export async function onPageLoad() {
4646
const navigate = useNavigate();
4747
const stateUrl = location.query.s;
4848
if (stateUrl) {
49-
return await loadStateFromURL(stateUrl);
49+
await loadStateFromURL(stateUrl);
50+
// Remove query parameter after loading state from URL,
51+
// as after editing the experiment the URL gets out of sync
52+
navigate("/");
53+
return;
5054
}
5155
const presetUrl = location.query.preset;
5256
if (presetUrl) {
@@ -118,8 +122,7 @@ export function saveToLocalStorage() {
118122
}
119123

120124
async function loadStateFromURL(url: string) {
121-
const navigate = useNavigate();
122-
showToastPromise(
125+
await showToastPromise(
123126
async () => {
124127
const response = await fetch(url);
125128
if (!response.ok) {
@@ -129,8 +132,6 @@ async function loadStateFromURL(url: string) {
129132
}
130133
const rawData = await response.text();
131134
await loadStateFromString(rawData);
132-
// clear ?e from URL after loading, as any edits would make URL a lie
133-
navigate("/");
134135
},
135136
{
136137
loading: "Loading experiment from URL...",

0 commit comments

Comments
 (0)