Skip to content
Snippets Groups Projects
Commit 03310e42 authored by kchadha's avatar kchadha
Browse files

Load button file input should only accept specific file extensions. Update...

Load button file input should only accept specific file extensions. Update load button to use new revamped loadProject function from VM. Loading a project via load button should clear the url hash (without triggering a reload or the project-loader-hoc).
parent dff72b62
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ const LoadButtonComponent = ({
{title}
</ButtonComponent>
<input
accept=".sb,.sb2,.sb3,.zip"
disabled
className={styles.fileInput}
ref={inputRef}
......
......@@ -25,8 +25,10 @@ class LoadButton extends React.Component {
}
handleChange (e) {
this.props.openLoadingState();
// Remove the hash if any (without triggering a hash change event or a reload)
history.replaceState({}, document.title, '.');
const reader = new FileReader();
reader.onload = () => this.props.vm.loadProjectLocal(reader.result)
reader.onload = () => this.props.vm.loadProject(reader.result)
.then(() => {
this.props.closeLoadingState();
})
......@@ -64,7 +66,7 @@ LoadButton.propTypes = {
closeLoadingState: PropTypes.func,
openLoadingState: PropTypes.func,
vm: PropTypes.shape({
loadProjectLocal: PropTypes.func
loadProject: PropTypes.func
})
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment