Fix cards state being not updated on touchables
Signed-off-by: Egor Savkin <es@m-labs.hk>
parent
a8e3bae08e
commit
0762572956
|
@ -540,6 +540,7 @@ class ProductCartItem extends React.PureComponent {
|
|||
onToggleWarning: PropTypes.func,
|
||||
onToggleOverlayRemove: PropTypes.func,
|
||||
onClickRemoveItem: PropTypes.func,
|
||||
onCardUpdate: PropTypes.func,
|
||||
shouldTooltipWarningClassInverted: PropTypes.bool,
|
||||
};
|
||||
}
|
||||
|
@ -623,6 +624,7 @@ class ProductCartItem extends React.PureComponent {
|
|||
index,
|
||||
ext_data,
|
||||
shouldTooltipWarningClassInverted,
|
||||
onCardUpdate,
|
||||
} = this.props;
|
||||
|
||||
let warning, options, options_data;
|
||||
|
@ -723,12 +725,12 @@ class ProductCartItem extends React.PureComponent {
|
|||
construct: ((outvar, value) => {
|
||||
// console.log("construct", outvar, value, options_data);
|
||||
options_data[outvar] = value;
|
||||
this.setState(options_data);
|
||||
onCardUpdate();
|
||||
}),
|
||||
update: ((outvar, value) => {
|
||||
// console.log("update", outvar, value, options_data);
|
||||
if (outvar in options_data) options_data[outvar] = value;
|
||||
this.setState(options_data);
|
||||
onCardUpdate();
|
||||
})
|
||||
}}
|
||||
/>) : null) }
|
||||
|
@ -857,6 +859,7 @@ class Cart extends React.PureComponent {
|
|||
onToggleWarning: PropTypes.func,
|
||||
onToggleOverlayRemove: PropTypes.func,
|
||||
onClickRemoveItem: PropTypes.func,
|
||||
onCardUpdate: PropTypes.func,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -870,6 +873,7 @@ class Cart extends React.PureComponent {
|
|||
onToggleWarning,
|
||||
onToggleOverlayRemove,
|
||||
onClickRemoveItem,
|
||||
onCardUpdate,
|
||||
} = this.props;
|
||||
|
||||
const nbrOccupied = nbrOccupiedSlotsInCrate(data.items);
|
||||
|
@ -897,6 +901,7 @@ class Cart extends React.PureComponent {
|
|||
onToggleWarning={onToggleWarning}
|
||||
onToggleOverlayRemove={onToggleOverlayRemove}
|
||||
onClickRemoveItem={onClickRemoveItem}
|
||||
onCardUpdate={onCardUpdate}
|
||||
model={item}>
|
||||
</ProductCartItem>
|
||||
);
|
||||
|
@ -1668,6 +1673,7 @@ class Shop extends React.PureComponent {
|
|||
this.handleClickShowOrder = this.handleClickShowOrder.bind(this);
|
||||
this.handleClickOpenImport = this.handleClickOpenImport.bind(this);
|
||||
this.handleLoadCustomConf = this.handleLoadCustomConf.bind(this);
|
||||
this.handleCardsUpdated = this.handleCardsUpdated.bind(this);
|
||||
|
||||
this.timer = null;
|
||||
}
|
||||
|
@ -1702,9 +1708,7 @@ class Shop extends React.PureComponent {
|
|||
(prevState.columns.cart.items !== this.state.columns.cart.items) ||
|
||||
(prevState.currentMode !== this.state.currentMode)
|
||||
) {
|
||||
this.checkAlerts(
|
||||
prevState.columns.cart.items,
|
||||
this.state.columns.cart.items);
|
||||
this.checkAlerts(this.state.columns.cart.items);
|
||||
}
|
||||
|
||||
if (this.state.newCardJustAdded) {
|
||||
|
@ -1720,6 +1724,10 @@ class Shop extends React.PureComponent {
|
|||
clearTimeout(this.timer);
|
||||
}
|
||||
|
||||
handleCardsUpdated() {
|
||||
this.checkAlerts(this.state.columns.cart.items);
|
||||
}
|
||||
|
||||
handleCrateModeChange(mode) {
|
||||
this.setState({
|
||||
currentMode: mode,
|
||||
|
@ -2091,7 +2099,7 @@ class Shop extends React.PureComponent {
|
|||
});
|
||||
}
|
||||
|
||||
checkAlerts(prevItems, newItems) {
|
||||
checkAlerts(newItems) {
|
||||
console.log('--- START CHECKING CRATE WARNING ---');
|
||||
|
||||
const {
|
||||
|
@ -2481,7 +2489,8 @@ class Shop extends React.PureComponent {
|
|||
onToggleProgress={this.handleToggleItemProgress}
|
||||
onToggleWarning={this.handleToggleItemWarning}
|
||||
onToggleOverlayRemove={this.handleToggleOverlayRemove}
|
||||
onClickRemoveItem={this.handleDeleteItem}>
|
||||
onClickRemoveItem={this.handleDeleteItem}
|
||||
onCardUpdate={this.handleCardsUpdated}>
|
||||
</Cart>
|
||||
}
|
||||
rules={Object.values(rules).filter(rule => rule)}>
|
||||
|
|
Loading…
Reference in New Issue