From 005525015ba571189572c09b0243c09fbf60ca1a Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Thu, 13 Feb 2025 10:23:31 -0700 Subject: [PATCH] Update recoil state set function for query interface --- .../custom/QueryBySet/QueryBySetInterface.tsx | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/packages/upset/src/components/custom/QueryBySet/QueryBySetInterface.tsx b/packages/upset/src/components/custom/QueryBySet/QueryBySetInterface.tsx index a18c5693..50e65b3c 100644 --- a/packages/upset/src/components/custom/QueryBySet/QueryBySetInterface.tsx +++ b/packages/upset/src/components/custom/QueryBySet/QueryBySetInterface.tsx @@ -1,4 +1,4 @@ -import { useRecoilState, useRecoilValue } from 'recoil'; +import { useRecoilValue, useSetRecoilState } from 'recoil'; import { css } from '@emotion/react'; import { Check, Edit } from '@mui/icons-material'; import { SvgIcon, Tooltip } from '@mui/material'; @@ -24,39 +24,6 @@ import { queryBySetsInterfaceAtom } from '../../../atoms/queryBySetsAtoms'; const EDIT_ICON_SIZE = 14; const CHECK_ICON_SIZE = 16; -/** - * Filters rows based on their set membership status according to the provided membership query. - * - * @param {Rows} r - The rows to be filtered. - * @param {SetQuery} membership - An object representing the membership query, where keys are set names and values are 'Yes', 'No', or 'May'. - * @returns {Row[]} - An array of rows that match the membership query. - * - * The function works by flattening the rows and then checking each row's set membership against the membership query. - * - If the membership status for a set is 'Yes', the row must belong to that set. - * - If the membership status for a set is 'No', the row must not belong to that set. - * - If the membership status for a set is 'May', the row is considered a match regardless of its membership in that set. - */ -// function getQueryResult(r: Rows, membership: SetQueryMembership): Row[] { -// const queryResults: Row[] = []; -// flattenRows(r).forEach((renderRow) => { -// let match = true; -// Object.entries(membership).forEach(([set, status]) => { -// if (status === 'Yes' && !getBelongingSetsFromSetMembership(renderRow.row.setMembership).includes(set)) { -// match = false; -// } -// if (status === 'No' && getBelongingSetsFromSetMembership(renderRow.row.setMembership).includes(set)) { -// match = false; -// } -// }); - -// if (match) { -// queryResults.push(renderRow.row); -// } -// }); - -// return queryResults; -// } - /** * Query by Set interface component. * @@ -68,7 +35,7 @@ export const QueryBySetInterface = () => { const data = useRecoilValue(dataAtom); const dimensions = useRecoilValue(dimensionsSelector); const visibleSets = useRecoilValue(visibleSetSelector); - const [_, setQueryInterface] = useRecoilState(queryBySetsInterfaceAtom); + const setQueryInterface = useSetRecoilState(queryBySetsInterfaceAtom); const [queryName, setQueryName] = useState('Query'); const [membership, setMembership] = useState({}); const rows = useMemo(() => getRows(data, provenance.getState(), true), [data, provenance.getState()]);