Browse Source

Fix development mode toggle

Thomas Dy 8 years ago
parent
commit
1bc85899e0
2 changed files with 5 additions and 3 deletions
  1. 2 1
      lib/stores.js
  2. 3 2
      lib/ui/Settings.jsx

+ 2 - 1
lib/stores.js

@@ -56,7 +56,8 @@ function setDevelopmentMode(name, value) {
   var domain = findDomain(name);
   return cloudflare.setDevelopmentMode(domain.id.val(), {value: value ? 'on' : 'off'}).then(function(data) {
     if(data.success) {
-      domain.development_mode.set(data.response.expires_on || 0);
+      var time = Date.now() / 1000 + (data.result.time_remaining || 0);
+      domain.development_mode.set(time);
     }
   });
 }

+ 3 - 2
lib/ui/Settings.jsx

@@ -14,10 +14,11 @@ var DevModeToggle = React.createClass({
     DomainStore.setDevelopmentMode(this.props.domain, this.props.devMode * 1000 <= Date.now());
   },
   render: function() {
+    var active = this.props.devMode * 1000 > Date.now();
     if(this.state.toggling) {
-      return <button className="btn btn-warning" disabled>{this.props.devMode > 0 ? 'Disabling...' : 'Enabling...'}</button>
+      return <button className="btn btn-warning" disabled>{active ? 'Disabling...' : 'Enabling...'}</button>
     }
-    else if(this.props.devMode * 1000 > Date.now()) {
+    else if(active) {
       var date = new Date(this.props.devMode*1000);
       return (
         <div>