Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
Signed-off-by: Ayoub LABIDI <[email protected]>
  • Loading branch information
ayolab committed Jul 10, 2024
1 parent ca98969 commit 0831ee9
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/components/diagrams/diagram-pane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,10 @@ export function DiagramPane({
// We debounce the updateNAD function to avoid generating unnecessary NADs
const debounceUpdateNAD = useDebounce(updateNAD, 300);

function shouldDebounceUpdateNAD(
estimatedNbVoltageLevels,
networkAreaDiagramDepth,
previousNetworkAreaDiagramDepth
) {
function shouldDebounceUpdateNAD(networkAreaDiagramDepth) {
const estimatedNbVoltageLevels = getEstimatedNbVoltageLevels(
networkAreaDiagramDepth
);
return (
estimatedNbVoltageLevels <
NETWORK_AREA_DIAGRAM_NB_MAX_VOLTAGE_LEVELS ||
Expand All @@ -684,17 +683,7 @@ export function DiagramPane({
// SLD MANAGEMENT (adding or removing SLDs)
updateSLDs(diagramStates);
// NAD MANAGEMENT (adding, removing or updating the NAD)
const estimatedNbVoltageLevels = getEstimatedNbVoltageLevels(
networkAreaDiagramDepth
);

if (
shouldDebounceUpdateNAD(
estimatedNbVoltageLevels,
networkAreaDiagramDepth,
previousNetworkAreaDiagramDepth.current
)
) {
if (shouldDebounceUpdateNAD(networkAreaDiagramDepth)) {
debounceUpdateNAD(diagramStates);
} else {
updateNAD(diagramStates);
Expand Down

0 comments on commit 0831ee9

Please sign in to comment.