Skip to content

Commit

Permalink
fix: Stop throwing errors when calling removeToolState if toolData or… (
Browse files Browse the repository at this point in the history
#1181)

* fix: Stop throwing errors when calling removeToolState if toolData or toolData.data do not exist

* chore: update autofix to new vscode format

* chore: apply autofix (fixes broken build)

Co-authored-by: Danny Brown <[email protected]>
  • Loading branch information
swederik and dannyrb authored Feb 20, 2020
1 parent 4e430ba commit 1682fa8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@
"[markdown]": {
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 80
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
5 changes: 5 additions & 0 deletions src/stateManagement/toolState.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ function getToolState(element, toolType) {
function removeToolState(element, toolType, data) {
const toolStateManager = getElementToolStateManager(element);
const toolData = toolStateManager.get(element, toolType);

if (!toolData || !toolData.data || !toolData.data.length) {
return;
}

// Find this tool data
let indexOfData = -1;

Expand Down
8 changes: 5 additions & 3 deletions src/tools/OverlayTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ export default class OverlayTool extends BaseTool {
}

// Guard against non-number values
const overlayX = (!isNaN(parseFloat(overlay.x)) && isFinite(overlay.x)) ? overlay.x : 0;
const overlayY = (!isNaN(parseFloat(overlay.y)) && isFinite(overlay.y)) ? overlay.y : 0;

const overlayX =
!isNaN(parseFloat(overlay.x)) && isFinite(overlay.x) ? overlay.x : 0;
const overlayY =
!isNaN(parseFloat(overlay.y)) && isFinite(overlay.y) ? overlay.y : 0;
// Draw the overlay layer onto the canvas

canvasContext.drawImage(layerCanvas, overlayX, overlayY);
});
}
Expand Down

0 comments on commit 1682fa8

Please sign in to comment.