Modals cleanup

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-08-22 16:46:46 +02:00
parent 7a2c77efa4
commit 5c047c4ef6
78 changed files with 387 additions and 664 deletions

View File

@ -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 };

View 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 };