mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +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) { |     createFeature: function (feature) { | ||||||
|         var unsaved = [], state = this.state; |         var created = function() { | ||||||
|  |             var unsaved = [], state = this.state; | ||||||
| 
 | 
 | ||||||
|         this.state.unsavedFeatures.forEach(function(f) { |             this.state.unsavedFeatures.forEach(function(f) { | ||||||
|             // TODO: make sure we don't overwrite an existing feature |                 // TODO: make sure we don't overwrite an existing feature | ||||||
|             if (f.name === feature.name) { |                 if (f.name === feature.name) { | ||||||
|                 state.savedFeatures.unshift(f); |                     state.savedFeatures.unshift(f); | ||||||
|             } else { |                 } else { | ||||||
|                 unsaved.push(f); |                     unsaved.push(f); | ||||||
|             } |                 } | ||||||
|         }); |             }); | ||||||
|  | 
 | ||||||
|  |             this.setState({unsavedFeatures: unsaved}); | ||||||
|  |         }.bind(this); | ||||||
| 
 | 
 | ||||||
|         this.setState({unsavedFeatures: unsaved}); |  | ||||||
| 
 | 
 | ||||||
|         this.state.featureStore.createFeature(feature) |         this.state.featureStore.createFeature(feature) | ||||||
|           .then(function(r) { console.log(r.statusText); }.bind(this)) |           .then(created) | ||||||
|           .catch(this.handleError); |           .catch(this.handleError); | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user