Skip to content

Commit

Permalink
fix(ui): Fixed virtual wall placement
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed May 28, 2020
1 parent b196625 commit 6724e55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions client/zone/js-modules/locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ export class VirtualWall {
this.active = false;
}

this.x1 = Math.min(x1, x2);
this.x2 = Math.max(x1, x2);
this.x1 = x1;
this.x2 = x2;

this.y1 = Math.min(y1, y2);
this.y2 = Math.max(y1, y2);
this.y1 = y1;
this.y2 = y2;
}

draw(ctx, transformFromMapSpace) {
Expand Down
11 changes: 8 additions & 3 deletions lib/devices/RoborockS5.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RoborockS5 extends Roborock {
async savePersistentData(persistantData) { //TODO: Store in valetudo config
if (Array.isArray(persistantData)) {
const flippedYCoordinates = persistantData.map(data => {
if (data[0] === 0) {
if (data[0] === PERSISTENT_DATA_TYPES.ZONE) {
// this is a zone
return [
data[0],
Expand All @@ -97,7 +97,6 @@ class RoborockS5 extends Roborock {
Tools.DIMENSION_MM - data[8]
];
} else {
// this is a barrier
return [
data[0],
data[1],
Expand All @@ -109,7 +108,7 @@ class RoborockS5 extends Roborock {
});

if (flippedYCoordinates.reduce((total, currentElem) => {
return total += currentElem[0] === 0 ? 4 : 2;
return total += currentElem[0] === PERSISTENT_DATA_TYPES.ZONE ? 4 : 2;
}, 0) > 68) {
throw new Error("too many forbidden markers to save!");
}
Expand Down Expand Up @@ -145,4 +144,10 @@ class RoborockS5 extends Roborock {
}
}

/** @enum {number} */
const PERSISTENT_DATA_TYPES = {
"ZONE": 0,
"BARRIER": 1
};

module.exports = RoborockS5;

0 comments on commit 6724e55

Please sign in to comment.