mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 05:32:41 +00:00
move test for autosave status to handleTextChange from trySave()
This commit is contained in:
@@ -25,6 +25,7 @@ const googleDriveActive = require('../../googleDrive.png');
|
|||||||
const googleDriveInactive = require('../../googleDriveMono.png');
|
const googleDriveInactive = require('../../googleDriveMono.png');
|
||||||
|
|
||||||
const SAVE_TIMEOUT = 3000;
|
const SAVE_TIMEOUT = 3000;
|
||||||
|
const AUTOSAVE_TIMEOUT = 10000;
|
||||||
|
|
||||||
const EditPage = createClass({
|
const EditPage = createClass({
|
||||||
displayName : 'EditPage',
|
displayName : 'EditPage',
|
||||||
@@ -120,14 +121,14 @@ const EditPage = createClass({
|
|||||||
brew : { ...prevState.brew, text: text },
|
brew : { ...prevState.brew, text: text },
|
||||||
isPending : true,
|
isPending : true,
|
||||||
htmlErrors : htmlErrors
|
htmlErrors : htmlErrors
|
||||||
}), ()=>this.trySave());
|
}), ()=>{if(this.state.autoSave) this.trySave();});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleStyleChange : function(style){
|
handleStyleChange : function(style){
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
brew : { ...prevState.brew, style: style },
|
brew : { ...prevState.brew, style: style },
|
||||||
isPending : true
|
isPending : true
|
||||||
}), ()=>this.trySave());
|
}), ()=>{if(this.state.autoSave) this.trySave();});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleMetaChange : function(metadata){
|
handleMetaChange : function(metadata){
|
||||||
@@ -137,7 +138,7 @@ const EditPage = createClass({
|
|||||||
...metadata
|
...metadata
|
||||||
},
|
},
|
||||||
isPending : true,
|
isPending : true,
|
||||||
}), ()=>this.trySave());
|
}), ()=>{if(this.state.autoSave) this.trySave();});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -146,7 +147,13 @@ const EditPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
trySave : function(){
|
trySave : function(){
|
||||||
if(!this.state.autoSave){return;};
|
// if(!this.state.autoSave){
|
||||||
|
// if(this.autoSaveInterval){
|
||||||
|
// clearInterval(this.autoSaveInterval);
|
||||||
|
// }
|
||||||
|
// this.autoSaveInterval = setInterval(this.trySave, 10000);
|
||||||
|
// return;
|
||||||
|
// };
|
||||||
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
|
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
|
||||||
if(this.hasChanges()){
|
if(this.hasChanges()){
|
||||||
this.debounceSave();
|
this.debounceSave();
|
||||||
@@ -351,7 +358,7 @@ const EditPage = createClass({
|
|||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
autoSave : !prevState.autoSave
|
autoSave : !prevState.autoSave
|
||||||
}), ()=>{
|
}), ()=>{
|
||||||
this.trySave();
|
if(this.state.autoSave) this.trySave();
|
||||||
localStorage.setItem('AUTOSAVE_ON', JSON.stringify(this.state.autoSave));
|
localStorage.setItem('AUTOSAVE_ON', JSON.stringify(this.state.autoSave));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user