mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 05:02:42 +00:00
tweak behavior per calculuschild notes
Default to autosave = true. trySave() when autosave toggled on. Display "auto-saved." when save is a result of autosave.
This commit is contained in:
@@ -63,7 +63,7 @@ const EditPage = createClass({
|
|||||||
errors : null,
|
errors : null,
|
||||||
htmlErrors : Markdown.validate(this.props.brew.text),
|
htmlErrors : Markdown.validate(this.props.brew.text),
|
||||||
url : '',
|
url : '',
|
||||||
autoSave : null
|
autoSave : true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
savedBrew : null,
|
savedBrew : null,
|
||||||
@@ -339,6 +339,9 @@ const EditPage = createClass({
|
|||||||
if(this.state.isPending && this.hasChanges()){
|
if(this.state.isPending && this.hasChanges()){
|
||||||
return <Nav.item className='save' onClick={this.save} color='blue' icon='fas fa-save'>Save Now</Nav.item>;
|
return <Nav.item className='save' onClick={this.save} color='blue' icon='fas fa-save'>Save Now</Nav.item>;
|
||||||
}
|
}
|
||||||
|
if(!this.state.isPending && !this.state.isSaving && this.state.autoSave){
|
||||||
|
return <Nav.item className='save saved'>auto-saved.</Nav.item>;
|
||||||
|
}
|
||||||
if(!this.state.isPending && !this.state.isSaving){
|
if(!this.state.isPending && !this.state.isSaving){
|
||||||
return <Nav.item className='save saved'>saved.</Nav.item>;
|
return <Nav.item className='save saved'>saved.</Nav.item>;
|
||||||
}
|
}
|
||||||
@@ -347,8 +350,10 @@ const EditPage = createClass({
|
|||||||
handleAutoSave : function(){
|
handleAutoSave : function(){
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
autoSave : !prevState.autoSave
|
autoSave : !prevState.autoSave
|
||||||
}));
|
}), ()=>{
|
||||||
localStorage.setItem('AUTOSAVE_ON', JSON.stringify(!this.state.autoSave));
|
this.trySave();
|
||||||
|
localStorage.setItem('AUTOSAVE_ON', JSON.stringify(this.state.autoSave));
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderAutoSaveButton : function(){
|
renderAutoSaveButton : function(){
|
||||||
|
|||||||
Reference in New Issue
Block a user