0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-28 09:12:45 +00:00

Rearrange so loading from one doesn't override the other

This commit is contained in:
Trevor Buckner
2021-06-25 00:15:49 -04:00
parent a171de32d8
commit 0616ce62eb

View File

@@ -64,18 +64,17 @@ const NewPage = createClass({
},
componentDidMount : function() {
const brewStorage = localStorage.getItem(BREWKEY);
if(!this.props.brew.text && brewStorage){
this.setState({
brew : { text: brewStorage }
});
};
const brewStorage = localStorage.getItem(BREWKEY);
const styleStorage = localStorage.getItem(STYLEKEY);
if(!this.props.brew.style && styleStorage){
if(!this.props.brew.text || !this.props.brew.style){
this.setState({
brew : { style: styleStorage }
brew : {
text : this.props.brew.text || (brewStorage ?? ''),
style : this.props.brew.style || (styleStorage ?? undefined)
}
});
};
}
this.setState((prevState)=>({
htmlErrors : Markdown.validate(prevState.brew.text)