Skip to content

Commit

Permalink
Settings: sync garbage collection in the URL
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTipson committed Sep 21, 2024
1 parent dd00110 commit d132c16
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/Machine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default function Machine({ examples, default_program }: { examples: Infer
const [settings, setSettingsOriginal] = useState<STGSettings>(() => {
const searchParams = new URLSearchParams(location.search);
return {
garbage_collection: true,
eval_apply: searchParams.has("ea") || false,
garbage_collection: !searchParams.has("nogc"),
eval_apply: searchParams.has("ea"),
collapse_indirections: true,
bind_names: false,
run_limit: 1000
Expand All @@ -81,9 +81,17 @@ export default function Machine({ examples, default_program }: { examples: Infer
} else {
searchParams.set("ea", "");
}
const newUrl = `${location.pathname}?${searchParams.toString()}`;
history.replaceState(null, '', newUrl);
}
const gc = !searchParams.has("nogc");
if (newSettings.garbage_collection !== gc) {
if (gc) {
searchParams.set("nogc", "");
} else {
searchParams.delete("nogc");
}
}
const newUrl = `${location.pathname}?${searchParams.toString()}`;
history.replaceState(null, '', newUrl);
};
const isDesktop = useMediaQuery("(min-width: 768px)");

Expand Down

0 comments on commit d132c16

Please sign in to comment.