Fix error with grid values being set to infinity and update map grid size verification

This commit is contained in:
Mitchell McCaffrey 2020-10-09 15:14:04 +11:00
parent e92a9acb5a
commit 1043f093cd
2 changed files with 6 additions and 6 deletions

View File

@ -63,7 +63,7 @@ function MapSettings({
let inset = map.grid.inset;
if (value > 0) {
if (gridX > 0) {
const gridScale =
((inset.bottomRight.x - inset.topLeft.x) * map.width) / gridX;
inset.bottomRight.y = (value * gridScale) / map.height;

View File

@ -50,13 +50,13 @@ function EditMapModal({ isOpen, onDone, map, mapState }) {
if (!isEmpty(mapSettingChanges) || !isEmpty(mapStateSettingChanges)) {
// Ensure grid values are positive
let verifiedChanges = { ...mapSettingChanges };
if ("gridX" in verifiedChanges) {
verifiedChanges.gridX = verifiedChanges.gridX || 1;
if ("grid" in verifiedChanges && "size" in verifiedChanges.grid) {
verifiedChanges.grid.size.x = verifiedChanges.grid.size.x || 1;
}
if ("gridY" in verifiedChanges) {
verifiedChanges.gridY = verifiedChanges.gridY || 1;
if ("grid" in verifiedChanges && "size" in verifiedChanges.grid) {
verifiedChanges.grid.size.y = verifiedChanges.grid.size.y || 1;
}
await updateMap(map.id, verifiedChanges);
await updateMap(map.id, mapSettingChanges);
await updateMapState(map.id, mapStateSettingChanges);
setMapSettingChanges({});