Fix error when deleting line (introduced with elevation feature)

pull/108/head
Candid Dauth 2017-05-11 02:53:56 +02:00
rodzic ed10477f7e
commit 050cd16737
1 zmienionych plików z 4 dodań i 6 usunięć

Wyświetl plik

@ -198,7 +198,7 @@ module.exports = function(Database) {
}); });
}, },
_setLinePoints(padId, lineId, trackPoints, _noEvent) { _setLinePoints(padId, lineId, trackPoints, _noEvent, _noUpdateLine) {
// First get elevation, so that if that fails, we don't update anything // First get elevation, so that if that fails, we don't update anything
let ascentDescent; let ascentDescent;
return this._updateElevation(trackPoints).then((a) => { return this._updateElevation(trackPoints).then((a) => {
@ -216,17 +216,15 @@ module.exports = function(Database) {
if(!_noEvent) if(!_noEvent)
this.emit("linePoints", padId, lineId, points); this.emit("linePoints", padId, lineId, points);
return this._updatePadObject("Line", padId, lineId, ascentDescent, true); if(!_noUpdateLine) // When deleting the line, we don't want to set this
}).then((newLine) => { return this._updatePadObject("Line", padId, lineId, ascentDescent, true);
if(!_noEvent)
this.emit("line", padId, newLine);
}); });
}, },
deleteLine(padId, lineId) { deleteLine(padId, lineId) {
return utils.promiseAuto({ return utils.promiseAuto({
line: this._deletePadObject("Line", padId, lineId), line: this._deletePadObject("Line", padId, lineId),
points: this._setLinePoints(padId, lineId, [ ], true) points: this._setLinePoints(padId, lineId, [ ], true, true)
}).then((res) => { }).then((res) => {
this.emit("deleteLine", padId, { id: lineId }); this.emit("deleteLine", padId, { id: lineId });