From 050ac675c030b9de6abde874d63c54aaaa80d0d6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 26 Jul 2019 15:08:26 +0300 Subject: more jsdoc --- vnext/src/api/index.js | 1 + vnext/src/ui/Feeds.js | 71 ++++++++++++++++++++++++++--------------------- vnext/src/ui/SearchBox.js | 12 +++----- vnext/src/ui/Settings.js | 20 ++++++------- 4 files changed, 53 insertions(+), 51 deletions(-) (limited to 'vnext/src') diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index 330b3f9e..50a9d5f9 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -57,6 +57,7 @@ const apiBaseUrl = 'https://juick.com'; * @property {string=} attach * @property {string=} timestamp * @property {boolean=} ReadOnly + * @property {number=} replyto */ diff --git a/vnext/src/ui/Feeds.js b/vnext/src/ui/Feeds.js index 39c1296b..8c79f779 100644 --- a/vnext/src/ui/Feeds.js +++ b/vnext/src/ui/Feeds.js @@ -11,6 +11,26 @@ import UserInfo from './UserInfo'; import { getMessages } from '../api'; +/** + * @typedef {Object} Query + * @property {string} baseUrl + * @property {Object=} search + * @property {string} pageParam + */ + +/** + * @typedef {Object} PageProps + * @property {import('history').History} history + * @property {import('history').Location} location + * @property {import('react-router').match} match + * @property {string} search + * @property {import('../api').SecureUser} visitor + * @property {import('../api').Message[]} msgs + */ + +/** + * @param {PageProps} props + */ export function Discover(props) { let search = qs.parse(props.location.search.substring(1)); const query = { @@ -21,6 +41,9 @@ export function Discover(props) { return (); } +/** + * @param {PageProps} props + */ export function Discussions(props) { const query = { baseUrl: '/api/messages/discussions', @@ -30,8 +53,7 @@ export function Discussions(props) { } /** - * Blog page - * @param {{match: import('react-router').match, location: import('history').Location}} props + * @param {PageProps} props */ export function Blog(props) { const { user } = props.match.params; @@ -52,6 +74,9 @@ export function Blog(props) { ); } +/** + * @param {PageProps} props + */ export function Tag(props) { const { tag } = props.match.params; const query = { @@ -64,6 +89,9 @@ export function Tag(props) { return (); } +/** + * @param {PageProps} props + */ export function Home(props) { const query = { baseUrl: '/api/home', @@ -72,6 +100,16 @@ export function Home(props) { return (); } +/** + * @param {{ + authRequired?: boolean, + visitor: import('../api').SecureUser, + history: import('history').History, + location: import('history').Location, + msgs: import('../api').Message[], + query: Query +}} props + */ function Feed(props) { const [msgs, setMsgs] = useState([]); const [loading, setLoading] = useState(true); @@ -144,32 +182,3 @@ function Feed(props) {
{nodes}
) : error ?
error
: loading ?
:
No more messages
; } -/* -Discover.propTypes = { - location: ReactRouterPropTypes.location.isRequired, - search: PropTypes.string -}; - -Blog.propTypes = { - match: ReactRouterPropTypes.match.isRequired, - location: ReactRouterPropTypes.location.isRequired, - search: PropTypes.string -}; - -Tag.propTypes = { - match: ReactRouterPropTypes.match.isRequired -}; - -Feed.propTypes = { - authRequired: PropTypes.bool, - visitor: UserType, - history: ReactRouterPropTypes.history.isRequired, - location: ReactRouterPropTypes.location.isRequired, - msgs: PropTypes.array, - query: PropTypes.shape({ - baseUrl: PropTypes.string.isRequired, - search: PropTypes.object, - pageParam: PropTypes.string.isRequired - }) -}; -*/ \ No newline at end of file diff --git a/vnext/src/ui/SearchBox.js b/vnext/src/ui/SearchBox.js index a79100cd..3f0b884b 100644 --- a/vnext/src/ui/SearchBox.js +++ b/vnext/src/ui/SearchBox.js @@ -1,9 +1,10 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import ReactRouterPropTypes from 'react-router-prop-types'; import { withRouter } from 'react-router-dom'; import { useFormState } from 'react-use-form-state'; +/** + * @param {{ pathname: string, onSearch: function, history: import('history').History }} props + */ function SearchBox({ onSearch, history, pathname }) { let onSubmit = (event) => { event.preventDefault(); @@ -13,14 +14,9 @@ function SearchBox({ onSearch, history, pathname }) { return (
+ placeholder="Search..." value={formState.values.search} {...text('search')} />
); } -SearchBox.propTypes = { - pathname: PropTypes.string.isRequired, - onSearch: PropTypes.func.isRequired, - history: ReactRouterPropTypes.history.isRequired -}; export default withRouter(SearchBox); diff --git a/vnext/src/ui/Settings.js b/vnext/src/ui/Settings.js index 61ac91d4..72537d86 100644 --- a/vnext/src/ui/Settings.js +++ b/vnext/src/ui/Settings.js @@ -7,6 +7,9 @@ import Icon from './Icon'; import UploadButton from './UploadButton'; import Avatar from './Avatar'; +/** + * @param {{ visitor: import('../api').User, onChange: function }} props + */ function ChangeAvatarForm({ visitor, onChange }) { const [avatar, setAvatar] = useState(''); const [preview, setPreview] = useState(); @@ -48,12 +51,10 @@ function ChangeAvatarForm({ visitor, onChange }) { ); } -/* -ChangeAvatarForm.propTypes = { - visitor: UserType.isRequired, - onChange: PropTypes.func.isRequired -}; -*/ + +/** + * @param {{ visitor: import('../api').User, onChange: React.ChangeEvent }} props + */ export default function Settings({ visitor, onChange }) { let passwordChanged = (event) => { @@ -243,10 +244,5 @@ export default function Settings({ visitor, onChange }) { ); } -/* -Settings.propTypes = { - visitor: UserType.isRequired, - onChange: PropTypes.func.isRequired -}; -*/ + -- cgit v1.2.3