Skip to content

Commit ad77959

Browse files
committed
refactor: simplify auto-detect and auto-fit branching logic in ResolutionMasterCanvas
Collapse four overlapping if/else branches into two primary paths plus two independent follow-up calls. The conditions on autoFitOnChange, autoDetect, and useCustomCalc were previously cross-multiplied across every combination, duplicating the same applyAutoFit/setDimensions calls. The new logic: 1. If autoFitOnChange && selectedCategory -> applyAutoFit (unified regardless of useCustomCalc). 2. Else if autoDetect -> set dimensions directly. 3. autoResizeOnChange and useCustomCalc are handled independently after the main branch so they still run when applicable. Also ensures useCustomCalc + selectedCategory triggers handleAutoCalc at the end, which was previously only reachable through one specific branch.
1 parent 7bd7656 commit ad77959

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

js/ResolutionMaster.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,34 +2658,21 @@ class ResolutionMasterCanvas {
26582658
this.manuallySetByAutoFit = false;
26592659

26602660
const props = node.properties;
2661-
if (props.autoDetect && !props.autoFitOnChange && !props.useCustomCalc) {
2662-
if (this.widthWidget && this.heightWidget) {
2663-
this.widthWidget.value = this.detectedDimensions.width;
2664-
this.heightWidget.value = this.detectedDimensions.height;
2665-
this.setDimensions(this.detectedDimensions.width, this.detectedDimensions.height);
2666-
}
2667-
}
2668-
else if (props.autoFitOnChange && !props.useCustomCalc && props.selectedCategory) {
2661+
if (props.autoFitOnChange && props.selectedCategory) {
26692662
this.applyAutoFit(this.detectedDimensions.width, this.detectedDimensions.height, false, props.selectedCategory, 'detected');
26702663
}
2671-
else if (props.autoFitOnChange && props.useCustomCalc && props.selectedCategory) {
2672-
this.applyAutoFit(this.detectedDimensions.width, this.detectedDimensions.height, true, props.selectedCategory, 'detected');
2673-
}
2674-
else if (props.autoDetect && !props.autoFitOnChange && props.useCustomCalc && props.selectedCategory) {
2675-
if (this.widthWidget && this.heightWidget) {
2676-
this.widthWidget.value = this.detectedDimensions.width;
2677-
this.heightWidget.value = this.detectedDimensions.height;
2678-
this.applyDimensionChange();
2679-
}
2680-
}
26812664
else if (props.autoDetect && this.widthWidget && this.heightWidget) {
26822665
this.widthWidget.value = this.detectedDimensions.width;
26832666
this.heightWidget.value = this.detectedDimensions.height;
26842667
this.setDimensions(this.detectedDimensions.width, this.detectedDimensions.height);
26852668
}
2669+
26862670
if (props.autoResizeOnChange) {
26872671
this.handleAutoResize();
26882672
}
2673+
if (props.useCustomCalc && props.selectedCategory) {
2674+
this.handleAutoCalc();
2675+
}
26892676

26902677
app.graph.setDirtyCanvas(true);
26912678
}

0 commit comments

Comments
 (0)