-
Notifications
You must be signed in to change notification settings - Fork 4
Change factor count calculation #967
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: main
Are you sure you want to change the base?
Conversation
e559374 to
a14074e
Compare
… into change-factor-count-calculation
| export interface FactorsCount { | ||
| resultCount: number; | ||
| variableCount: number; | ||
| } |
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.
not really a constant
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.
fixed!
| ); | ||
| }; | ||
|
|
||
| export const useFactorCountDisplay = (count: number, maxCount: number, messageId: string, launchLoader: boolean) => { |
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.
launchLoader -> isLoading ?
I saw it's base on old code though, no need to change it here I think
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.
let's change it :)
| ); | ||
| }; | ||
|
|
||
| export const useFactorCountDisplay = (count: number, maxCount: number, messageId: string, launchLoader: boolean) => { |
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.
hook returning JSX ?
make this file a component instead
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.
fixed!
| ) | ||
| .map((entry) => entry[COUNT]) | ||
| .reduce((a, b) => a + b, 0); | ||
| const getFactorsCount = useCallback(() => { |
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.
| const getFactorsCount = useCallback(() => { | |
| const updateFactorCount = useCallback(() => { |
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.
fixed!
| const [sensitivityAnalysisParams, setSensitivityAnalysisParams] = useState(params); | ||
| const { snackError } = useSnackMessage(); | ||
| const [analysisComputeComplexity, setAnalysisComputeComplexity] = useState(0); | ||
| const [factorsCount, setFactorsCount] = useState<FactorsCount>({ resultCount: 0, variableCount: 0 }); |
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.
| const [factorsCount, setFactorsCount] = useState<FactorsCount>({ resultCount: 0, variableCount: 0 }); | |
| const [factorsCount, setFactorsCount] = useState<FactorsCount>(DEFAULT_FACTOR_COUNT); |
Then reuse it at line 169
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.
fixed!
| formatNewParams(filteredFormValues) | ||
| ) | ||
| .then((response) => { | ||
| response.text().then((value: string) => { |
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.
make this transformation in getSensitivityAnalysisFactorsCount directly to prevent promise chaining here
use backendFetchText ?
You could even use backendFetchJson so you don't have to parse it yourself
I'm confused that you need to parseInt yourself
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.
Fixed! I did not change the existing code (https://github.com/gridsuite/commons-ui/pull/967/changes#diff-17f4a437a70614bc66b84276022b6e01a917a2dba012ad66966df80c6d78128bL236-L242) but I really don't know why we went that way... Fixed in 6681389
| const timeoutId = setTimeout(() => { | ||
| setLaunchLoader(false); | ||
| }, 500); | ||
| return () => clearTimeout(timeoutId); |
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.
as discussed, this is weird, but we'll leave it since it was here before
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.
Agreed, probably need some ref/use effect to increase robustness...
f184871 to
b18f0af
Compare
|


PR Summary