diff options
author | Vitaly Takmazov | 2019-08-15 09:56:12 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:55 +0300 |
commit | adf830dfcd1350e104b92a0f088e5664a35b7b15 (patch) | |
tree | d3c1537144ba33fdddd975b39f8b8d1bf0057c30 /vnext/src/ui | |
parent | 30723a1df4688c421ccd8ec7b9d804c0bd3d020a (diff) |
jsdoc updates
Diffstat (limited to 'vnext/src/ui')
-rw-r--r-- | vnext/src/ui/MessageInput.js | 15 | ||||
-rw-r--r-- | vnext/src/ui/SearchBox.js | 15 | ||||
-rw-r--r-- | vnext/src/ui/Thread.js | 9 | ||||
-rw-r--r-- | vnext/src/ui/UserInfo.js | 4 |
4 files changed, 37 insertions, 6 deletions
diff --git a/vnext/src/ui/MessageInput.js b/vnext/src/ui/MessageInput.js index bc9ddd54..e19136d4 100644 --- a/vnext/src/ui/MessageInput.js +++ b/vnext/src/ui/MessageInput.js @@ -26,11 +26,13 @@ function moveCaretToEnd(el) { * @property {string} text * @property {import('../api').Message} data * @property {function} onSend + * @property {number} rows + * @property {string} children */ /** * MessageInput - * @param {HTMLTextAreaElement & MessageInputProps} props + * @param {React.ReactNode & MessageInputProps} props */ export default function MessageInput({ text, data, rows, children, onSend }) { /** @@ -98,7 +100,7 @@ export default function MessageInput({ text, data, rows, children, onSend }) { <div style={commentStyle}> <textarea onChange={textChanged} onKeyPress={handleCtrlEnter} ref={textareaRef} style={textInputStyle} - rows={rows || '1'} placeholder={children} value={body} /> + rows={rows || 1} placeholder={children} value={body} /> <div style={inputBarStyle}> <UploadButton inputRef={fileinput} value={attach} onChange={uploadValueChanged} /> <Button onClick={onSubmit}><Icon name="ei-envelope" size="s" />Send</Button> @@ -108,6 +110,9 @@ export default function MessageInput({ text, data, rows, children, onSend }) { ); } +/** + * @type {React.CSSProperties} + */ const commentStyle = { display: 'flex', flexDirection: 'column', @@ -115,6 +120,9 @@ const commentStyle = { marginTop: '10px' }; +/** + * @type {React.CSSProperties} + */ const inputBarStyle = { display: 'flex', alignItems: 'center', @@ -122,6 +130,9 @@ const inputBarStyle = { padding: '3px' }; +/** + * @type {React.CSSProperties} + */ const textInputStyle = { overflow: 'hidden', resize: 'none', diff --git a/vnext/src/ui/SearchBox.js b/vnext/src/ui/SearchBox.js index 3f0b884b..aab49757 100644 --- a/vnext/src/ui/SearchBox.js +++ b/vnext/src/ui/SearchBox.js @@ -3,9 +3,22 @@ import { withRouter } from 'react-router-dom'; import { useFormState } from 'react-use-form-state'; /** - * @param {{ pathname: string, onSearch: function, history: import('history').History }} props + * @typedef {Object} SearchBoxPropsFields + * @property {string} pathname + * @property {function} onSearch + */ + + /** + * @typedef {import('react-router-dom').RouteComponentProps & SearchBoxPropsFields} SearchBoxProps + */ + +/** + * @param {SearchBoxProps} props */ function SearchBox({ onSearch, history, pathname }) { + /** + * @type {(React.FormEvent<HTMLFormElement>)} + */ let onSubmit = (event) => { event.preventDefault(); onSearch(history, pathname, formState.values.search); diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js index e469b8cf..cbd40c4c 100644 --- a/vnext/src/ui/Thread.js +++ b/vnext/src/ui/Thread.js @@ -16,6 +16,10 @@ import { bubbleStyle, chatItemStyle } from './helpers/BubbleStyle'; import './Thread.css'; let isMounted; +/** + * @type import('../api').Message + */ +const emptyMessage = {}; /** * @param {{ @@ -122,7 +126,8 @@ export default function Thread(props) { const [replies, setReplies] = useState([]); const [loading, setLoading] = useState(false); const [active, setActive] = useState(0); - const [editing, setEditing] = useState({}); + + const [editing, setEditing] = useState(emptyMessage); const [hash, setHash] = useState(props.visitor.hash); const { mid } = props.match.params; @@ -162,7 +167,7 @@ export default function Thread(props) { const { mid, rid, body, attach } = template; let commentAction = editing.rid ? update(mid, editing.rid, body) : comment(mid, rid, body, attach); commentAction.then(res => { - setEditing({}); + setEditing(emptyMessage); loadReplies(); }) .catch(console.log); diff --git a/vnext/src/ui/UserInfo.js b/vnext/src/ui/UserInfo.js index 6ff64931..ccdd5c04 100644 --- a/vnext/src/ui/UserInfo.js +++ b/vnext/src/ui/UserInfo.js @@ -86,7 +86,9 @@ function Summary({ user }) { let presentItems = [read, readers, mybl].filter(Boolean); return ( <div className="msg-summary"> - {presentItems.length > 0 && presentItems.reduce((prev, curr) => [prev, ' ', curr])} + {presentItems.length > 0 && presentItems.reduce((prev, curr) => + // @ts-ignore + [prev, ' ', curr])} </div> ); } |