mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
only optimistic update if success
This commit is contained in:
parent
b2d4cbf5de
commit
c6118baad3
@ -64,21 +64,24 @@ var Unleash = React.createClass({
|
||||
},
|
||||
|
||||
createFeature: function (feature) {
|
||||
var unsaved = [], state = this.state;
|
||||
var created = function() {
|
||||
var unsaved = [], state = this.state;
|
||||
|
||||
this.state.unsavedFeatures.forEach(function(f) {
|
||||
// TODO: make sure we don't overwrite an existing feature
|
||||
if (f.name === feature.name) {
|
||||
state.savedFeatures.unshift(f);
|
||||
} else {
|
||||
unsaved.push(f);
|
||||
}
|
||||
});
|
||||
this.state.unsavedFeatures.forEach(function(f) {
|
||||
// TODO: make sure we don't overwrite an existing feature
|
||||
if (f.name === feature.name) {
|
||||
state.savedFeatures.unshift(f);
|
||||
} else {
|
||||
unsaved.push(f);
|
||||
}
|
||||
});
|
||||
|
||||
this.setState({unsavedFeatures: unsaved});
|
||||
}.bind(this);
|
||||
|
||||
this.setState({unsavedFeatures: unsaved});
|
||||
|
||||
this.state.featureStore.createFeature(feature)
|
||||
.then(function(r) { console.log(r.statusText); }.bind(this))
|
||||
.then(created)
|
||||
.catch(this.handleError);
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user