-
Notifications
You must be signed in to change notification settings - Fork 16
FIREFLY-1943: React Compiler bugs #1922
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
base: dev
Are you sure you want to change the base?
Changes from all commits
07b0882
b233af3
6b4b61a
9b0cb5f
6ff9f62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,12 +28,7 @@ import {DEF_TARGET_PANEL_KEY} from '../TargetPanel.jsx'; | |||||
| import {ConstraintContext} from './Constraints.js'; | ||||||
| import {ROW_POSITION, SEARCH_POSITION} from './Cutout'; | ||||||
| import {getDataServiceOption} from './DataServicesOptions'; | ||||||
| import { | ||||||
| DebugObsCore, | ||||||
| getPanelPrefix, | ||||||
| makeCollapsibleCheckHeader, | ||||||
| makeFieldErrorList, | ||||||
| makePanelStatusUpdater, | ||||||
| import {DebugObsCore, getPanelPrefix, makeCollapsibleCheckHeader, makeFieldErrorList, | ||||||
| } from './TableSearchHelpers.jsx'; | ||||||
| import {showUploadTableChooser} from '../UploadTableChooser.js'; | ||||||
| import { | ||||||
|
|
@@ -134,16 +129,13 @@ export function SpatialSearch({sx, cols, serviceUrl, serviceLabel, serviceId, co | |||||
|
|
||||||
| const {setConstraintFragment}= useContext(ConstraintContext); | ||||||
| const {setVal,getVal,makeFldObj}= useContext(FieldGroupCtx); | ||||||
| const [constraintResult, setConstraintResult] = useState({}); | ||||||
| const [getUploadInfo, setUploadInfo]= useFieldGroupValue('uploadInfo'); | ||||||
| const [posDefaultOpenMsg, setPosDefaultOpenMsg]= useState(true); | ||||||
|
|
||||||
| useFieldGroupRerender([...fldListAry, ...collapsibleCheckHeaderKeys]); // force rerender on any change | ||||||
|
|
||||||
| const uploadInfo= getUploadInfo() || undefined; | ||||||
|
|
||||||
| const updatePanelStatus= makePanelStatusUpdater(checkHeaderCtl.isPanelActive(), Spatial); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| if (!canUpload) setVal(SPATIAL_TYPE,SINGLE); | ||||||
| }, [serviceUrl,canUpload]); | ||||||
|
|
@@ -236,15 +228,52 @@ export function SpatialSearch({sx, cols, serviceUrl, serviceLabel, serviceId, co | |||||
|
|
||||||
| useFieldGroupWatch([cornerCalcType], () => onChangeToPolygonMethod()); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| const constraints= makeSpatialConstraints(columnsModel, obsCoreEnabled, makeFldObj(fldListAry), uploadInfo, tableName, canUpload,useSIAv2); | ||||||
| updatePanelStatus(constraints, constraintResult, setConstraintResult,useSIAv2); | ||||||
| }); | ||||||
|
|
||||||
| const targetWp = getVal(ServerParams.USER_TARGET_WORLD_PT); | ||||||
| const spatialRegOp = getVal(SpatialRegOp); | ||||||
| const spatialType = getVal(SPATIAL_TYPE); | ||||||
| const spatialMethodVal = getVal(SpatialMethod); | ||||||
| const radiusVal = getVal(RadiusSize); | ||||||
| const polygonCornersVal = getVal(PolygonCorners); | ||||||
| const centerLonVal = getVal(CenterLonColumns); | ||||||
| const centerLatVal = getVal(CenterLatColumns); | ||||||
| const uploadCenterLonVal = getVal(UploadCenterLonColumns); | ||||||
| const uploadCenterLatVal = getVal(UploadCenterLatColumns); | ||||||
| const cornerCalcTypeVal = getVal(cornerCalcType); | ||||||
| const closestVal = getVal(Closest); | ||||||
|
|
||||||
| const isSpatialPanelActive = checkHeaderCtl?.isPanelActive(); | ||||||
|
|
||||||
| const constraintResult = React.useMemo(() => { | ||||||
|
|
||||||
| //when spatial panel is inactive, it should not contribute constraints or errors | ||||||
| if (!isSpatialPanelActive) { | ||||||
| return { | ||||||
| adqlConstraintsAry: [], | ||||||
| constraintErrors: [], | ||||||
| simpleError: '', | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
| const constraints = makeSpatialConstraints( | ||||||
| columnsModel, obsCoreEnabled, makeFldObj(fldListAry), | ||||||
| uploadInfo, tableName, canUpload, useSIAv2 | ||||||
| ); | ||||||
|
|
||||||
| return { | ||||||
| ...constraints, | ||||||
| constraintErrors: [...(constraints.errAry ?? [])], | ||||||
| simpleError: constraints.errAry?.[0] ?? '', | ||||||
| }; | ||||||
| }, [isSpatialPanelActive, columnsModel, obsCoreEnabled, uploadInfo, tableName, canUpload, | ||||||
| useSIAv2, targetWp, spatialRegOp, spatialType, spatialMethodVal, | ||||||
| radiusVal, polygonCornersVal, centerLonVal, centerLatVal, | ||||||
| uploadCenterLonVal, uploadCenterLatVal, cornerCalcTypeVal, closestVal, | ||||||
| ]); | ||||||
kpuriIpac marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really like this approach. It is much clean and easier to follow. However, I think it is to verbose and hard to consistently reuse. So here are a couple of ideas. this will help a lot fldListAry.mapIdea 1define in function makeConstrainstHelper(active, make) {
if (!active) return { adqlConstraintsAry: [], constraintErrors: [], simpleError: '', };
const constraints = make();
return {
...constraints,
constraintErrors: [...(constraints.errAry ?? [])],
simpleError: constraints.errAry?.[0] ?? '',
};
}then your use Memo function const constraintResult = React.useMemo(() => {
return doContrains(
isSpatialPanelActive,
() => makeSpatialConstraints( columnsModel, obsCoreEnabled, makeFldObj(fldListAry),
uploadInfo, tableName, canUpload, useSIAv2)
);
}, [...fldListAry.map((v)=> getVal(v)) ]);Idea 2define in then const constraintResult1 = React.useMemo(() => {
if (!isSpatialPanelActive) return makeEmptyConstrains();
const constraints = makeSpatialConstraints(
columnsModel, obsCoreEnabled, makeFldObj(fldListAry),
uploadInfo, tableName, canUpload, useSIAv2
);
return makeConstrainstEntry(constraints);
}, [...fldListAry.map((v)=> getVal(v)) ]);
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vote for idea 2 |
||||||
| useEffect(() => { | ||||||
| setConstraintFragment(panelPrefix, constraintResult); | ||||||
| return () => setConstraintFragment(panelPrefix, ''); | ||||||
| }, [constraintResult]); | ||||||
| }, [panelPrefix, setConstraintFragment, constraintResult]); | ||||||
|
|
||||||
| if (disablePanel) { | ||||||
| return ( | ||||||
|
|
@@ -321,13 +350,11 @@ function getSpacialLayoutMode(spacialType, obsCoreEnabled, canUpload) { | |||||
| const SpatialSearchLayout = ({initArgs, obsCoreEnabled, uploadInfo, setUploadInfo, serviceLabel, serviceId, | ||||||
| hipsUrl, centerWP, fovDeg, capabilities, embeddedInHiPS, slotProps}) => { | ||||||
|
|
||||||
| const {getVal}= useContext(FieldGroupCtx); | ||||||
|
|
||||||
| const spacialType= getVal(SPATIAL_TYPE) ?? SINGLE; | ||||||
| const spatialMethod= getVal(SpatialMethod)??CONE_CHOICE_KEY; | ||||||
| const closest= getVal(Closest)??''; | ||||||
| const cornerCalcTypeValue= getVal(cornerCalcType)??'image'; | ||||||
| const spatialRegOpValue= getVal(SpatialRegOp) ?? SpatialRegOpType.CONTAINS_POINT; | ||||||
| const spacialType = useFieldGroupValue(SPATIAL_TYPE)[0]() ?? SINGLE; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This maybe just preference issue, I find useStoreConnector cleaner for these cases. I consider useFieldGroupValue more for cases where I want a getter function that I'll call later.
Suggested change
You can get groupKey by doing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to stay consistent with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could defined this in SimpleComponent. I think it would work. There are many uses. export function useFieldValueOnly(fieldKey, def, gk) {
return useFieldGroupValue(fieldKey,gk)[0]() ?? def;
} |
||||||
| const spatialMethod = useFieldGroupValue(SpatialMethod)[0]() ?? CONE_CHOICE_KEY; | ||||||
| const closest = useFieldGroupValue(Closest)[0]() ?? ''; | ||||||
| const cornerCalcTypeValue = useFieldGroupValue(cornerCalcType)[0]() ?? 'image'; | ||||||
| const spatialRegOpValue = useFieldGroupValue(SpatialRegOp)[0]() ?? SpatialRegOpType.CONTAINS_POINT; | ||||||
|
Comment on lines
+353
to
+357
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good. I think I went down the wrong path using getVal here. |
||||||
| const layoutMode= getSpacialLayoutMode(spacialType,obsCoreEnabled,capabilities?.canUpload); | ||||||
| const isCone= spatialMethod === CONE_CHOICE_KEY; | ||||||
| const containsPoint= spatialRegOpValue === SpatialRegOpType.CONTAINS_POINT; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good!
getAdqlConstraintsListis a real improvement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add some sort of
hasErrorsto work withconstraintObj.constraintErrors?.lengthor call isisContraintsValid