Skip to content

Commit

Permalink
Consolidate query boolean checks in isQueryBoolean
Browse files Browse the repository at this point in the history
  • Loading branch information
joverlee521 committed Nov 19, 2024
1 parent 30a2dcd commit cb77d9c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/actions/measurements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ interface GroupingValues {
/* mf_<field> correspond to active measurements filters */
const filterQueryPrefix = "mf_";
type MeasurementsFilterQuery = `mf_${string}`
type QueryBoolean = "show" | "hide"

const queryBooleanValues = ["show", "hide"] as const;
type QueryBoolean = (typeof queryBooleanValues)[number]
export const isQueryBoolean = (x: any): x is QueryBoolean => queryBooleanValues.includes(x)
/* Measurements query parameters that are constructed and/or parsed here. */
interface MeasurementsQuery {
m_collection?: string
Expand Down Expand Up @@ -656,13 +659,12 @@ export const combineMeasurementsControlsAndQuery = (
}
break;
case "m_overallMean":
if (queryValue === "show" || queryValue === "hide") {
if (isQueryBoolean(queryValue)) {
newControlState = queryValue === "show";
}
break;
case "m_threshold":
if (collectionToDisplay.thresholds &&
(queryValue === "show" || queryValue === "hide")) {
if (collectionToDisplay.thresholds && isQueryBoolean(queryValue)) {
newControlState = queryValue === "show";
}
break;
Expand Down

0 comments on commit cb77d9c

Please sign in to comment.