@ -1,25 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { uploadCompose } from 'soapbox/actions/compose';
|
||||
|
||||
import UploadButton from '../components/upload-button';
|
||||
|
||||
import type { IntlShape } from 'react-intl';
|
||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||
|
||||
const mapStateToProps = (state: RootState, { composeId }: { composeId: string }) => ({
|
||||
disabled: state.compose.get(composeId)?.is_uploading,
|
||||
resetFileKey: state.compose.get(composeId)?.resetFileKey!,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch: AppDispatch, { composeId }: { composeId: string }) => ({
|
||||
|
||||
onSelectFile(files: FileList, intl: IntlShape) {
|
||||
dispatch(uploadCompose(composeId, files, intl));
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
const UploadButtonContainer = connect(mapStateToProps, mapDispatchToProps)(UploadButton);
|
||||
|
||||
export { UploadButtonContainer as default };
|
||||
28
src/features/compose/containers/upload-button-container.tsx
Normal file
28
src/features/compose/containers/upload-button-container.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
|
||||
import { uploadCompose } from 'soapbox/actions/compose';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
|
||||
import UploadButton from '../components/upload-button';
|
||||
|
||||
import type { IntlShape } from 'react-intl';
|
||||
|
||||
interface IUploadButtonContainer {
|
||||
composeId: string;
|
||||
}
|
||||
|
||||
const UploadButtonContainer: React.FC<IUploadButtonContainer> = ({ composeId }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { disabled, resetFileKey } = useAppSelector((state) => ({
|
||||
disabled: state.compose.get(composeId)?.is_uploading,
|
||||
resetFileKey: state.compose.get(composeId)?.resetFileKey!,
|
||||
}));
|
||||
|
||||
const onSelectFile = (files: FileList, intl: IntlShape) => {
|
||||
dispatch(uploadCompose(composeId, files, intl));
|
||||
};
|
||||
|
||||
return <UploadButton disabled={disabled} resetFileKey={resetFileKey} onSelectFile={onSelectFile} />;
|
||||
};
|
||||
|
||||
export { UploadButtonContainer as default };
|
||||
Reference in New Issue
Block a user