From 03310e42a3a7a113dfe8b2322f642fe30c62bcdd Mon Sep 17 00:00:00 2001 From: kchadha <kchadha@scratch.mit.edu> Date: Wed, 14 Mar 2018 15:16:19 -0400 Subject: [PATCH] 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). --- src/components/load-button/load-button.jsx | 1 + src/containers/load-button.jsx | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/load-button/load-button.jsx b/src/components/load-button/load-button.jsx index 0f580278c..2623b7118 100644 --- a/src/components/load-button/load-button.jsx +++ b/src/components/load-button/load-button.jsx @@ -25,6 +25,7 @@ const LoadButtonComponent = ({ {title} </ButtonComponent> <input + accept=".sb,.sb2,.sb3,.zip" disabled className={styles.fileInput} ref={inputRef} diff --git a/src/containers/load-button.jsx b/src/containers/load-button.jsx index b3804d8c5..e52a6735d 100644 --- a/src/containers/load-button.jsx +++ b/src/containers/load-button.jsx @@ -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 }) }; -- GitLab