1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

added message editing button

This commit is contained in:
Fedor Katurov 2020-09-07 15:22:27 +07:00
parent a0d18076ad
commit 4c4a33a819
5 changed files with 67 additions and 28 deletions

View file

@ -18,21 +18,27 @@ const mapDispatchToProps = {
authSendMessage: AUTH_ACTIONS.authSendMessage,
};
type IProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & {};
type IProps = ReturnType<typeof mapStateToProps> &
typeof mapDispatchToProps & {
id?: number;
text?: string;
};
const MessageFormUnconnected: FC<IProps> = ({
id = 0,
text: initialText = '',
profile: { is_sending_messages, is_loading_messages, messages_error },
authSendMessage,
}) => {
const [text, setText] = useState('');
const [text, setText] = useState(initialText);
const onSuccess = useCallback(() => {
setText('');
}, [setText]);
const onSubmit = useCallback(() => {
authSendMessage({ text }, onSuccess);
}, [authSendMessage, text, onSuccess]);
authSendMessage({ text, id }, onSuccess);
}, [authSendMessage, text, id, onSuccess]);
const onKeyDown = useCallback<KeyboardEventHandler<HTMLTextAreaElement>>(
({ ctrlKey, key }) => {
@ -82,9 +88,6 @@ const MessageFormUnconnected: FC<IProps> = ({
);
};
const MessageForm = connect(
mapStateToProps,
mapDispatchToProps
)(MessageFormUnconnected);
const MessageForm = connect(mapStateToProps, mapDispatchToProps)(MessageFormUnconnected);
export { MessageForm };