Webclient: Handle firing an event once (#4499)

* draft: handle firing an event once

* lint

* Prevent rapid double-click on sending messages

* no rest spread on single primative when sibling components exist

* clear message instead of using a fireOnce handler.

* fix tests

* remove unnecessary validate mock
This commit is contained in:
Brent Clark 2022-01-30 11:14:28 -06:00 committed by GitHub
parent 4bb13677c8
commit 513fcb0908
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 21467 additions and 161 deletions

View file

@ -1,18 +1,24 @@
// eslint-disable-next-line
import React from "react";
import { connect } from 'react-redux';
import { Form, reduxForm } from 'redux-form'
import React from 'react';
import { Form } from 'react-final-form'
import { InputAction } from 'components';
const SayMessage = ({ handleSubmit }) => (
<Form onSubmit={handleSubmit}>
<InputAction action="Send" label="Chat" name="message" />
</Form>
);
const required = (value) => (value ? undefined : 'Required');
const propsMap = {
form: 'sayMessage'
};
const SayMessage = (props) => {
const { onSubmit } = props
return (
<Form onSubmit={values => onSubmit(values)}>
{({ handleSubmit, form }) => (
<form onSubmit={e => {
handleSubmit(e)
form.restart()
}}>
<InputAction action="Send" label="Chat" name="message" validate={required}/>
</form>
)}
</Form>
);
}
export default connect()(reduxForm(propsMap)(SayMessage));
export default SayMessage;