From 7f25b0f261b5a5fc2696054004fb24673375b91b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 6 Jul 2018 01:32:43 +0300 Subject: Proptypes & eslint --- vnext/src/api/index.js | 18 +++++++++--------- vnext/src/components/Button.js | 2 +- vnext/src/components/Chat.js | 13 ++++++++++--- vnext/src/components/Contact.js | 5 +++++ vnext/src/components/Contacts.js | 12 ++++++------ vnext/src/components/Feeds.js | 15 ++++++++++++--- vnext/src/components/Footer.js | 4 ++-- vnext/src/components/Header.js | 27 ++++++++++++++++----------- vnext/src/components/Icon.js | 2 +- vnext/src/components/Message.js | 7 ++++--- vnext/src/components/MessageInput.js | 20 ++++++++++---------- vnext/src/components/PM.js | 11 +++++++++-- vnext/src/components/Post.js | 25 +++++++++++++++++-------- vnext/src/components/Settings.js | 10 +++++----- vnext/src/components/Spinner.js | 2 +- vnext/src/components/Thread.js | 23 +++++++++++++++++------ vnext/src/index.js | 4 ++-- 17 files changed, 127 insertions(+), 73 deletions(-) (limited to 'vnext/src') diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index 653360f5..74280ed5 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -19,14 +19,14 @@ export function me(username = '', password = '') { client.get('/me', { headers: username ? { - 'Authorization': 'Basic ' + window.btoa(unescape(encodeURIComponent(username + ":" + password))) + 'Authorization': 'Basic ' + window.btoa(unescape(encodeURIComponent(username + ':' + password))) } : {} }).then(response => { localStorage.visitor = JSON.stringify(response.data); - resolve(response.data) + resolve(response.data); }).catch(reason => { - localStorage.clear() - reject(reason) + localStorage.clear(); + reject(reason); }) }); } @@ -57,9 +57,9 @@ export function getMessages(path, params) { } export function post(body, attach) { - let form = new FormData() - form.append('attach', attach) - form.append('body', body) + let form = new FormData(); + form.append('attach', attach); + form.append('body', body); return client.post('/post', form); } @@ -69,7 +69,7 @@ export function comment(mid, rid, body, attach) { form.append('rid', rid); form.append('body', body); form.append('attach', attach); - return client.post('/comment', form) + return client.post('/comment', form); } function socialLink(network) { @@ -86,4 +86,4 @@ export function vkLink() { export function markReadTracker(msg, visitor) { return `${apiBaseUrl}/thread/mark_read/${msg.mid}-${msg.rid || 0}.gif?hash=${visitor.hash}`; -} \ No newline at end of file +} diff --git a/vnext/src/components/Button.js b/vnext/src/components/Button.js index 583f8e4b..656c0426 100644 --- a/vnext/src/components/Button.js +++ b/vnext/src/components/Button.js @@ -1,4 +1,4 @@ -import React from 'react' +import React from 'react'; export default function Button(props) { return ( diff --git a/vnext/src/components/Chat.js b/vnext/src/components/Chat.js index 916de003..dd94dd9e 100644 --- a/vnext/src/components/Chat.js +++ b/vnext/src/components/Chat.js @@ -1,4 +1,6 @@ import React from 'react'; +import ReactRouterPropTypes from 'react-router-prop-types'; +import { UserType } from './Types'; import moment from 'moment'; import PM from './PM'; @@ -14,7 +16,7 @@ export default class Chat extends React.Component { chats: [] }; } - componentWillMount() { + componentDidMount() { this.loadChat(this.props.match.params.user); } @@ -57,14 +59,14 @@ export default class Chat extends React.Component { {uname ? (
-
@@ -78,6 +80,11 @@ export default class Chat extends React.Component { } } +Chat.propTypes = { + visitor: UserType.isRequired, + match: ReactRouterPropTypes.match.isRequired +}; + const chatStyle = { boxSizing: 'border-box', padding: '0 20px', diff --git a/vnext/src/components/Contact.js b/vnext/src/components/Contact.js index 0e969cc1..01dd1ae6 100644 --- a/vnext/src/components/Contact.js +++ b/vnext/src/components/Contact.js @@ -1,4 +1,5 @@ import React from 'react'; +import { UserType } from './Types'; import Avatar from './Avatar'; @@ -14,3 +15,7 @@ export default class Contact extends React.Component { ); } } + +Contact.propTypes = { + user: UserType +}; diff --git a/vnext/src/components/Contacts.js b/vnext/src/components/Contacts.js index 3f2e7288..84a6ec9f 100644 --- a/vnext/src/components/Contacts.js +++ b/vnext/src/components/Contacts.js @@ -1,4 +1,5 @@ import React from 'react'; + import { getChats } from '../api'; @@ -11,7 +12,7 @@ export default class Contacts extends React.Component { pms: [] }; } - componentWillMount() { + componentDidMount() { this.refreshChats(); } @@ -26,11 +27,10 @@ export default class Contacts extends React.Component { } render() { const { pms } = this.state; - const user = this.props.visitor; return (
-