Fix error with grid values being set to infinity and update map grid size verification
This commit is contained in:
parent
e92a9acb5a
commit
1043f093cd
@ -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;
|
||||
|
@ -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({});
|
||||
|
Loading…
Reference in New Issue
Block a user