fix issue #321 - load defaults, then localStorage, then url config (#322)

* fix issue #321 - load defaults, then localStorage, then url config

* update comment and also do not need current state
main
Steven Sacks 7 years ago committed by Michael Fix
parent f49b7649fb
commit 9e519e2b5f

1
.gitignore vendored

@ -3,3 +3,4 @@ node_modules
.next .next
cypress/videos cypress/videos
cypress/screenshots cypress/screenshots
.idea

@ -41,14 +41,11 @@ const saveButtonOptions = {
class Editor extends React.Component { class Editor extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = Object.assign( this.state = {
{ ...DEFAULT_SETTINGS,
...DEFAULT_SETTINGS, uploading: false,
uploading: false, code: props.content
code: props.content }
},
this.props.initialState
)
this.save = this.save.bind(this) this.save = this.save.bind(this)
this.upload = this.upload.bind(this) this.upload = this.upload.bind(this)
@ -65,13 +62,11 @@ class Editor extends React.Component {
} }
componentDidMount() { componentDidMount() {
// Load from localStorage instead of query params // Load from localStorage and then URL params
if (!this.props.initialState) { this.setState({
const state = getState(localStorage) ...getState(localStorage),
if (state) { ...this.props.initialState
this.setState(state) })
}
}
} }
componentDidUpdate() { componentDidUpdate() {

Loading…
Cancel
Save