mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 12:22:44 +00:00
save autosave setting to localStorage
This commit is contained in:
@@ -63,12 +63,14 @@ const EditPage = createClass({
|
|||||||
errors : null,
|
errors : null,
|
||||||
htmlErrors : Markdown.validate(this.props.brew.text),
|
htmlErrors : Markdown.validate(this.props.brew.text),
|
||||||
url : '',
|
url : '',
|
||||||
autoSave : true
|
autoSave : null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
savedBrew : null,
|
savedBrew : null,
|
||||||
|
|
||||||
componentDidMount : function(){
|
componentDidMount : function(){
|
||||||
|
this.setState({ autoSave: JSON.parse(localStorage.getItem('AUTOSAVE_ON')) });
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
url : window.location.href
|
url : window.location.href
|
||||||
});
|
});
|
||||||
@@ -382,7 +384,12 @@ const EditPage = createClass({
|
|||||||
{this.renderGoogleDriveIcon()}
|
{this.renderGoogleDriveIcon()}
|
||||||
<Nav.dropdown className='save-menu'>
|
<Nav.dropdown className='save-menu'>
|
||||||
{this.renderSaveButton()}
|
{this.renderSaveButton()}
|
||||||
<Nav.item onClick={()=>{ this.setState((prevState)=>({ autoSave: !prevState.autoSave }));}}>
|
<Nav.item onClick={()=>{
|
||||||
|
this.setState((prevState)=>({
|
||||||
|
autoSave : !prevState.autoSave
|
||||||
|
}));
|
||||||
|
localStorage.setItem('AUTOSAVE_ON', JSON.stringify(!this.state.autoSave));
|
||||||
|
}}>
|
||||||
Autosave <i className={this.state.autoSave ? 'fas fa-power-off active' : 'fas fa-power-off'}></i>
|
Autosave <i className={this.state.autoSave ? 'fas fa-power-off active' : 'fas fa-power-off'}></i>
|
||||||
|
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
|
|||||||
Reference in New Issue
Block a user