fix plant selection bugs

This commit is contained in:
gabrielburnworth 2018-01-29 18:59:37 -08:00
parent c532f1426a
commit d6b0a7d396
2 changed files with 8 additions and 4 deletions

View file

@ -2,7 +2,7 @@ import * as React from "react";
import { t } from "i18next";
import { error } from "farmbot-toastr";
import { Plant, DEFAULT_PLANT_RADIUS } from "../plant";
import { movePlant, closePlantInfo } from "../actions";
import { movePlant, closePlantInfo, unselectPlant } from "../actions";
import * as moment from "moment";
import { GardenMapProps, GardenMapState } from "../interfaces";
import { getPathArray } from "../../history";
@ -65,6 +65,10 @@ export class GardenMap extends
this.state = {};
}
componentWillUnmount() {
unselectPlant(this.props.dispatch)();
}
get isEditing(): boolean { return getMode() === Mode.editPlant; }
endDrag = () => {

View file

@ -54,10 +54,10 @@ export class SelectPlants
}
componentWillUnmount() {
this.props.dispatch({ type: Actions.SELECT_PLANT, payload: undefined });
this.unstashSelectedPlant();
}
onBack = () => {
unstashSelectedPlant = () => {
const { stashedUuid, stashedIcon } = this.state;
this.props.dispatch({ type: Actions.SELECT_PLANT, payload: [stashedUuid] });
this.props.dispatch({
@ -88,7 +88,7 @@ export class SelectPlants
className="panel-container green-panel plant-selection-panel">
<div className="panel-header green-panel">
<p className="panel-title">
<BackArrow onClick={this.onBack} />
<BackArrow onClick={this.unstashSelectedPlant} />
{t("Select plants")}
</p>