diff --git a/app/soapbox/features/forms/index.js b/app/soapbox/features/forms/index.js
index 82e778e31..bd1b93252 100644
--- a/app/soapbox/features/forms/index.js
+++ b/app/soapbox/features/forms/index.js
@@ -270,5 +270,5 @@ export const FileChooserCSV = props => (
);
FileChooserCSV.defaultProps = {
- accept: ['.csv'],
+ accept: ['text/csv'],
};
diff --git a/app/soapbox/features/import_data/index.js b/app/soapbox/features/import_data/index.js
index 39e305c64..e414b26e2 100644
--- a/app/soapbox/features/import_data/index.js
+++ b/app/soapbox/features/import_data/index.js
@@ -15,52 +15,40 @@ const messages = defineMessages({
heading: { id: 'column.import_data', defaultMessage: 'Import data' },
});
-export default @injectIntl
+export default @connect()
+@injectIntl
class ImportData extends ImmutablePureComponent {
- constructor(props) {
- super(props);
- this.state = {
- list: null,
- };
- }
-
static propTypes = {
dispatch: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
state = {
+ followsCSV: null,
isLoading: false,
}
handleSubmit = (event) => {
const { dispatch } = this.props;
+
let params = new FormData();
- params.append('list', this.state.list);
+ params.append('list', this.state.followsCSV);
+
+ this.setState({ isLoading: true });
dispatch(importFollows(params)).then(() => {
this.setState({ isLoading: false });
}).catch((error) => {
this.setState({ isLoading: false });
});
- this.setState({ isLoading: true });
+
event.preventDefault();
}
- handleChange = (e) => {
- const content = e.target.result;
- this.setState({
- list: content,
- });
- };
-
- handleFileChange = path => {
- return e => {
- let fileData = new FileReader();
- fileData.onloadend = this.handleChange;
- fileData.readAsText(e.target.files[0]);
- };
- };
+ handleFileChange = e => {
+ const [followsCSV] = e.target.files || [];
+ this.setState({ followsCSV });
+ }
render() {
const { intl } = this.props;
@@ -76,7 +64,7 @@ class ImportData extends ImmutablePureComponent {
label={}
name='follows'
hint={}
- onChange={this.handleFileChange('follows')}
+ onChange={this.handleFileChange}
/>