move localStorage.clear() to prop of Editor (#484)

main
Michael Fix 6 years ago committed by GitHub
parent 2c619fbcb6
commit 09fa737ca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -205,7 +205,7 @@ class Editor extends React.Component {
resetDefaultSettings() {
this.setState(DEFAULT_SETTINGS)
localStorage.clear()
this.props.onReset()
}
upload() {
@ -374,7 +374,8 @@ function readAs(file) {
Editor.defaultProps = {
api: {},
onUpdate: () => {}
onUpdate: () => {},
onReset: () => {}
}
export default DragDropContext(HTML5Backend)(Editor)

@ -20,13 +20,24 @@ class Index extends React.Component {
}
render() {
const { router } = this.props
return (
<Page enableHeroText={true}>
<Editor {...router} onUpdate={this.onEditorUpdate} api={api} />
<Editor {...this.props.router} onUpdate={this.onEditorUpdate} api={api} onReset={onReset} />
</Page>
)
}
}
function onReset() {
localStorage.clear()
if (window.navigator && navigator.serviceWorker) {
navigator.serviceWorker.getRegistrations().then(registrations => {
for (let registration of registrations) {
registration.unregister()
}
})
}
}
export default withRouter(Index)

Loading…
Cancel
Save