diff --git a/web/modals/threads/new-thread-modal.react.js b/web/modals/threads/new-thread-modal.react.js index 6bdf8de40..06fbeb432 100644 --- a/web/modals/threads/new-thread-modal.react.js +++ b/web/modals/threads/new-thread-modal.react.js @@ -1,303 +1,303 @@ // @flow import invariant from 'invariant'; -import PropTypes from 'prop-types'; import * as React from 'react'; import { newThreadActionTypes, newThread } from 'lib/actions/thread-actions'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors'; import { threadInfoSelector } from 'lib/selectors/thread-selectors'; import { generateRandomColor, threadTypeDescriptions, } from 'lib/shared/thread-utils'; import { type ThreadInfo, - threadInfoPropType, threadTypes, assertThreadType, type ThreadType, type NewThreadRequest, type NewThreadResult, } from 'lib/types/thread-types'; -import type { DispatchActionPromise } from 'lib/utils/action-utils'; -import { connect } from 'lib/utils/redux-utils'; +import { + type DispatchActionPromise, + useDispatchActionPromise, + useServerCall, +} from 'lib/utils/action-utils'; -import type { AppState } from '../../redux/redux-setup'; +import { useSelector } from '../../redux/redux-utils'; import css from '../../style.css'; import Modal from '../modal.react'; import ColorPicker from './color-picker.react'; -type Props = { - onClose: () => void, - parentThreadID?: ?string, - // Redux state - inputDisabled: boolean, - parentThreadInfo: ?ThreadInfo, - // Redux dispatch functions - dispatchActionPromise: DispatchActionPromise, - // async functions that hit server APIs - newThread: (request: NewThreadRequest) => Promise, -}; -type State = { - threadType: ?ThreadType, - name: string, - description: string, - color: string, - errorMessage: string, -}; +type BaseProps = {| + +onClose: () => void, + +parentThreadID?: ?string, +|}; +type Props = {| + ...BaseProps, + +inputDisabled: boolean, + +parentThreadInfo: ?ThreadInfo, + +dispatchActionPromise: DispatchActionPromise, + +newThread: (request: NewThreadRequest) => Promise, +|}; +type State = {| + +threadType: ?ThreadType, + +name: string, + +description: string, + +color: string, + +errorMessage: string, +|}; class NewThreadModal extends React.PureComponent { - static propTypes = { - onClose: PropTypes.func.isRequired, - parentThreadID: PropTypes.string, - inputDisabled: PropTypes.bool.isRequired, - parentThreadInfo: threadInfoPropType, - dispatchActionPromise: PropTypes.func.isRequired, - newThread: PropTypes.func.isRequired, - }; nameInput: ?HTMLInputElement; openPrivacyInput: ?HTMLInputElement; threadPasswordInput: ?HTMLInputElement; constructor(props: Props) { super(props); this.state = { threadType: props.parentThreadID ? undefined : threadTypes.CHAT_SECRET, name: '', description: '', color: props.parentThreadInfo ? props.parentThreadInfo.color : generateRandomColor(), errorMessage: '', }; } componentDidMount() { invariant(this.nameInput, 'nameInput ref unset'); this.nameInput.focus(); } render() { let threadTypeSection = null; if (this.props.parentThreadID) { threadTypeSection = (
Thread type
); } return (
Thread name
Description