Cleanup unsaved FarmEvents
This commit is contained in:
parent
8880f7bc9e
commit
ae32ec0933
|
@ -3,7 +3,7 @@ import { t } from "i18next";
|
|||
import * as moment from "moment";
|
||||
import { connect } from "react-redux";
|
||||
import { mapStateToPropsAddEdit, } from "./map_state_to_props_add_edit";
|
||||
import { init } from "../../api/crud";
|
||||
import { init, destroy } from "../../api/crud";
|
||||
import { EditFEForm } from "./edit_fe_form";
|
||||
import { betterCompact, JSXChildren, catchErrors } from "../../util";
|
||||
import { entries } from "../../resources/util";
|
||||
|
@ -65,6 +65,16 @@ export class AddFarmEvent
|
|||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
const { uuid } = this.state;
|
||||
// Legacy leftover from pre-TaggedResource era.
|
||||
// TODO: Proper fix where we add a `findFarmEvent` selector
|
||||
// to mapStateToProps instead of juggling arrays.
|
||||
const fe = uuid && this.props.farmEvents.filter(x => x.uuid === uuid)[0];
|
||||
const unsaved = fe && !fe.body.id;
|
||||
if (fe && unsaved) { this.props.dispatch(destroy(fe.uuid, true)); }
|
||||
}
|
||||
|
||||
/** No executables. Can't load form. */
|
||||
none() {
|
||||
return <p>
|
||||
|
|
Loading…
Reference in a new issue