Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indexed BooleanFields in Lightning Mode #4139

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion app/packages/core/src/components/Common/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LoadingDots, useTheme } from "@fiftyone/components";
import { Checkbox as MaterialCheckbox } from "@mui/material";
import { animated } from "@react-spring/web";
import React, { useMemo } from "react";
import { constSelector, RecoilValueReadOnly } from "recoil";
import { RecoilValueReadOnly, constSelector } from "recoil";
import styled from "styled-components";
import { prettify } from "../../utils/generic";
import { ItemAction } from "../Actions/ItemAction";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const Checkboxes = ({

const show = useRecoilValue(showSearchSelector({ modal, path }));
const keypoints = useRecoilValue(isInKeypointsField(path));
const lightning = useRecoilValue(fos.isLightningPath(path));

if (loading) {
return <LoadingDots text={"Loading"} />;
Expand All @@ -186,7 +187,8 @@ const Checkboxes = ({
name={value === null ? "None" : value}
loading={loading}
count={
typeof count !== "number" || !isFilterMode || keypoints
(typeof count !== "number" || !isFilterMode || keypoints) &&
!lightning
? // only string and id fields use pathSearchCount
pathSearchCount({ modal, path, value: value as string })
: count
Expand Down
8 changes: 2 additions & 6 deletions app/packages/state/src/recoil/pathData/boolean.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { selectorFamily } from "recoil";
import { aggregation } from "../aggregations";
import { isLightningPath, lightning } from "../lightning";
import { noneCount } from "./counts";
import { lightningBooleanResults } from "./lightningBoolean";

export const booleanResults = selectorFamily<
Expand All @@ -19,7 +18,7 @@ export const booleanResults = selectorFamily<
return get(lightningBooleanResults(params));
}

return booleanCountResults(params);
return get(booleanCountResults(params));
},
});

Expand All @@ -29,7 +28,6 @@ export const booleanCountResults = selectorFamily({
(params: { path: string; modal: boolean; extended: boolean }) =>
({ get }) => {
const data = get(aggregation(params));
const none = get(noneCount(params));

if (data.__typename !== "BooleanAggregation") {
throw new Error("unexpected");
Expand All @@ -42,9 +40,7 @@ export const booleanCountResults = selectorFamily({
{ value: "True", count: data.true },
].filter(({ count }) => count),
};
if (none) {
result.results.push({ value: null, count: none });
}

return result;
},
});
4 changes: 3 additions & 1 deletion app/packages/state/src/recoil/pathData/lightningBoolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const lightningBooleanResults = selectorFamily<
const [data] = get(lightningQuery([{ path: params.path }]));

if (data.__typename !== "BooleanLightningResult") {
throw new Error("unexpected");
throw new Error(
`unexpected ${data.__typename} for path '${params.path}' in lightningBooleanResults`
);
}

return {
Expand Down
2 changes: 1 addition & 1 deletion app/packages/state/src/recoil/pathData/lightningNumeric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const lightningNumericResults = selectorFamily({
}

throw new Error(
`unexpected type '${data.__typename}' for path '${path}'`
`unexpected ${data.__typename} for path '${path}' in lightningNumericResults`
);
},
});
Expand Down
4 changes: 3 additions & 1 deletion app/packages/state/src/recoil/pathData/lightningString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export const lightningStringResults = selectorFamily<
const [data] = get(lightningQuery([params]));

if (data.__typename !== "StringLightningResult") {
throw new Error("bad");
throw new Error(
`unexpected ${data.__typename} for path '${params.path}' in lightningStringResults`
);
}

if (!data.values) {
Expand Down
Loading