Skip to content

Commit

Permalink
front: Allow sharing a URL with a comparison result
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Sep 17, 2024
1 parent bd9a7de commit f51d5a4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions web/src/components/Solver.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,25 @@ export function JointRulesDisplay({optionsLeft, optionsRight, style}) {
export function CompareDisplay({optionsLeft, optionsRight, setInputQuery, setMode}) {
const [patDepth, setPatDepth] = useStateInParams('pat_d', 3, parseInt);
const [tyDepth, setTyDepth] = useStateInParams('ty_d', 4, parseInt);
const [showCompare, setShowCompare] = useState(false);
const [showCompare, setShowCompare] = useStateInParams('do_cmp', false, (x) => x == 'true');
// The input used in the last computation.
const [compareInput, setCompareInput] = useState(null);
const [compareInput, setCompareInput] = useState(() => {
if (showCompare) {
// If `showCompare` is true on init, this comes from the url so we should compare the input.
return { optionsLeft, optionsRight, patDepth, tyDepth }
} else {
return null
}
});
// The output of the last computation.
const [output, setOutput] = useState(null);
const [output, setOutput] = useState(() => {
if (showCompare) {
// If `showCompare` is true on init, this comes from the url so we should compare the input.
return compare_rulesets_js(optionsLeft, optionsRight, patDepth, tyDepth)
} else {
return null
}
});

// Reset output if the options change.
useEffect(() => {
Expand Down

0 comments on commit f51d5a4

Please sign in to comment.