Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/playground/src/pages/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const Edit = () => {
},
};

// The scratchpad resource reads localStorage before this effect runs, so a hash import must refetch it.
const [scratchpadVersion, setScratchpadVersion] = createSignal(0);
createEffect(() => {
if (!scratchpad()) return;
if (location.query.hash) {
Expand All @@ -104,6 +106,7 @@ export const Edit = () => {
files: initialTabs.map((x) => ({ name: x.name, content: x.source })),
}),
);
setScratchpadVersion((v) => v + 1);
navigate('/', { replace: true });
}
});
Expand Down Expand Up @@ -189,8 +192,11 @@ export const Edit = () => {
context.setSolidVersion(undefined);
});

const [resource, { mutate }] = createResource<APIRepl, { repl: string | undefined; scratchpad: boolean }>(
() => ({ repl: params.repl, scratchpad: !!scratchpad() }),
const [resource, { mutate }] = createResource<
APIRepl,
{ repl: string | undefined; scratchpad: boolean; scratchpadVersion: number }
>(
() => ({ repl: params.repl, scratchpad: !!scratchpad(), scratchpadVersion: scratchpadVersion() }),
async ({ repl, scratchpad }): Promise<APIRepl> => {
if (disableFetch) {
disableFetch = undefined;
Expand Down