소스 검색

Move finishSave to componentWillUpdateProps

This synchronizes the update in Cortex and the rerender. Before there
was a slight flash of old content.
Thomas Dy 10 년 전
부모
커밋
d02957bc97
1개의 변경된 파일6개의 추가작업 그리고 8개의 파일을 삭제
  1. 6 8
      lib/ui/RecordList.jsx

+ 6 - 8
lib/ui/RecordList.jsx

@@ -70,6 +70,9 @@ var Record = React.createClass({
   getInitialState: function() {
     return {state: 'view', saving: false};
   },
+  componentWillReceiveProps: function() {
+    this.setState({state: 'view', saving: false});
+  },
   setDeleting: function() {
     this.setState({state: 'delete'});
   },
@@ -79,15 +82,10 @@ var Record = React.createClass({
   cancelEdit: function() {
     this.setState({state: 'view'});
   },
-  finishSave: function(promise) {
-    promise.then(function() {
-      this.setState({state: 'view', saving: false});
-    }.bind(this));
-  },
   commitDelete: function() {
     this.setState({saving: true});
     var record = this.props.record;
-    this.finishSave(DomainStore.remove(record.zone_name.val(), record.rec_id.val()));
+    DomainStore.remove(record.zone_name.val(), record.rec_id.val());
   },
   commitEdit: function() {
     this.setState({saving: true});
@@ -101,7 +99,7 @@ var Record = React.createClass({
     if(record.service_mode.val()) {
       newRecord.service_mode = record.service_mode.val();
     }
-    this.finishSave(DomainStore.edit(record.zone_name.val(), newRecord));
+    DomainStore.edit(record.zone_name.val(), newRecord);
   },
   toggleProxy: function() {
     this.setState({saving: true});
@@ -113,7 +111,7 @@ var Record = React.createClass({
       content: record.content.val(),
       service_mode: record.service_mode.val() === "1" ? "0" : "1"
     };
-    this.finishSave(DomainStore.edit(record.zone_name.val(), newRecord));
+    DomainStore.edit(record.zone_name.val(), newRecord);
   },
   render: function() {
     var record = this.props.record;