fix react-js warnings

This commit is contained in:
or-else
2018-09-11 20:44:21 +03:00
parent c768755ae4
commit ce20a86072
3 changed files with 29 additions and 17 deletions
+3 -3
View File
@@ -1164,15 +1164,15 @@ i.search {
margin-right: 0.8rem; margin-right: 0.8rem;
} }
.chat-box .bubble p { .chat-box .bubble div.message-content {
color: #212121; color: #212121;
margin: 0; margin: 0;
max-width: 36rem; max-width: 36rem;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
/* The timestamp is a floating element. Need to ensure p is expanded /* The timestamp is a floating element. Need to ensure div.message-content is expanded
* to accomodate it. It's usually called clearfix. */ * to accomodate it. It's usually called clearfix. */
.chat-box .bubble p:after { .chat-box .bubble div.message-content:after {
content: "."; content: ".";
display: block; display: block;
height: 0; height: 0;
+2 -2
View File
@@ -29,8 +29,8 @@
<!-- Styles for local elements --> <!-- Styles for local elements -->
<link rel="stylesheet" href="css/base.css" /> <link rel="stylesheet" href="css/base.css" />
<!-- ReactJs scripts --> <!-- ReactJs scripts -->
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script> <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script> <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"></script> <script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
</head> </head>
<body> <body>
+24 -12
View File
@@ -533,6 +533,9 @@ class ContextMenu extends React.Component {
e.stopPropagation(); e.stopPropagation();
this.props.hide(); this.props.hide();
let item = this.props.items[e.currentTarget.dataset.id]; let item = this.props.items[e.currentTarget.dataset.id];
if (typeof item == 'string') {
item = this.MenuItems[item];
}
item.handler(this.props.params, this.props.onError); item.handler(this.props.params, this.props.onError);
} }
@@ -1245,7 +1248,7 @@ class LoginView extends React.Component {
<div className="panel-form-row"> <div className="panel-form-row">
<CheckBox id="save-token" name="save-token" checked={this.state.saveToken} <CheckBox id="save-token" name="save-token" checked={this.state.saveToken}
onChange={this.handleToggleSaveToken} /> onChange={this.handleToggleSaveToken} />
<label forHtml="save-token">&nbsp;Keep me logged in</label> <label htmlFor="save-token">&nbsp;Keep me logged in</label>
</div> </div>
<div className="dialog-buttons"> <div className="dialog-buttons">
<button className={submitClasses} type="submit">Sign in</button> <button className={submitClasses} type="submit">Sign in</button>
@@ -1357,7 +1360,7 @@ class CreateAccountView extends React.PureComponent {
<div className="panel-form-row"> <div className="panel-form-row">
<CheckBox id="save-token" name="save-token" checked={this.state.saveToken} <CheckBox id="save-token" name="save-token" checked={this.state.saveToken}
onChange={this.handleToggleSaveToken} /> onChange={this.handleToggleSaveToken} />
<label forHtml="save-token">&nbsp;Keep me logged in</label> <label htmlFor="save-token">&nbsp;Keep me logged in</label>
</div> </div>
<div className="dialog-buttons"> <div className="dialog-buttons">
<button className={submitClasses} type="submit">Sign up</button> <button className={submitClasses} type="submit">Sign up</button>
@@ -1489,13 +1492,13 @@ class SettingsView extends React.PureComponent {
return ( return (
<form id="settings-form" onSubmit={this.handleSubmit}> <form id="settings-form" onSubmit={this.handleSubmit}>
<div className="panel-form-row"> <div className="panel-form-row">
<label forHtml="message-sound">Message sound:</label> <label htmlFor="message-sound">Message sound:</label>
<CheckBox name="sound" id="message-sound" <CheckBox name="sound" id="message-sound"
checked={this.state.messageSounds} checked={this.state.messageSounds}
onChange={this.handleCheckboxClick} /> onChange={this.handleCheckboxClick} />
</div> </div>
<div className="panel-form-row"> <div className="panel-form-row">
<label forHtml="desktop-alerts">Notification alerts{!this.props.desktopAlertsEnabled ? ' (requires HTTPS)' : null}:</label> <label htmlFor="desktop-alerts">Notification alerts{!this.props.desktopAlertsEnabled ? ' (requires HTTPS)' : null}:</label>
<CheckBox name="alert" id="desktop-alerts" <CheckBox name="alert" id="desktop-alerts"
checked={this.state.desktopAlerts} checked={this.state.desktopAlerts}
onChange={this.props.desktopAlertsEnabled ? this.handleCheckboxClick : null} /> onChange={this.props.desktopAlertsEnabled ? this.handleCheckboxClick : null} />
@@ -3388,7 +3391,7 @@ class ChatMessage extends React.Component {
null} null}
<div> <div>
<div className={bubbleClass}> <div className={bubbleClass}>
<p>{content} <div className="content">{content}
{attachments} {attachments}
<ReceivedMarker <ReceivedMarker
timestamp={this.props.timestamp} timestamp={this.props.timestamp}
@@ -4295,8 +4298,6 @@ class TinodeWeb extends React.Component {
this.handleHideInfoView = this.handleHideInfoView.bind(this); this.handleHideInfoView = this.handleHideInfoView.bind(this);
this.handleMemberUpdateRequest = this.handleMemberUpdateRequest.bind(this); this.handleMemberUpdateRequest = this.handleMemberUpdateRequest.bind(this);
this.handleValidateCredentialsRequest = this.handleValidateCredentialsRequest.bind(this); this.handleValidateCredentialsRequest = this.handleValidateCredentialsRequest.bind(this);
this.handleHashRoute();
} }
getBlankState() { getBlankState() {
@@ -4339,7 +4340,7 @@ class TinodeWeb extends React.Component {
contextMenuParams: null, contextMenuParams: null,
contextMenuItems: [], contextMenuItems: [],
contactsSearchQuery: undefined, contactsSearchQuery: '',
// Chats as shown in the ContactsView // Chats as shown in the ContactsView
chatList: [], chatList: [],
// Contacts returned by a search query. // Contacts returned by a search query.
@@ -4390,6 +4391,8 @@ class TinodeWeb extends React.Component {
} }
this.readTimer = null; this.readTimer = null;
this.readTimerCallback = null; this.readTimerCallback = null;
this.handleHashRoute();
} }
componentWillUnmount() { componentWillUnmount() {
@@ -4765,6 +4768,8 @@ class TinodeWeb extends React.Component {
// User clicked on a contact in the side panel or deleted a contact. // User clicked on a contact in the side panel or deleted a contact.
handleTopicSelected(topicName, unused_index, online, acs) { handleTopicSelected(topicName, unused_index, online, acs) {
console.log("handleTopicSelected", topicName, online, acs);
if (topicName) { if (topicName) {
// Contact selected // Contact selected
if (this.state.topicSelected != topicName) { if (this.state.topicSelected != topicName) {
@@ -4802,19 +4807,25 @@ class TinodeWeb extends React.Component {
navigateTo(setUrlTopic(window.location.hash, null)); navigateTo(setUrlTopic(window.location.hash, null));
} }
// User is sending a message, either plain text or a drafty object with attachments. // User is sending a message, either plain text or a drafty object, possibly
// with attachments.
handleSendMessage(msg, promise, uploader) { handleSendMessage(msg, promise, uploader) {
let topic = this.state.tinode.getTopic(this.state.topicSelected); let topic = this.state.tinode.getTopic(this.state.topicSelected);
let dft = Drafty.parse(msg);
let mimeType, attachments; let mimeType, attachments;
let dft = typeof msg == 'string' ? Drafty.parse(msg) : msg;
if (dft && !Drafty.isPlainText(dft)) { if (dft && !Drafty.isPlainText(dft)) {
msg = dft; msg = dft;
mimeType = Drafty.getContentType(); mimeType = Drafty.getContentType();
if (Drafty.hasAttachments(data)) { if (Drafty.hasAttachments(msg)) {
attachments = []; attachments = [];
Drafty.attachments(data, (val) => { attachments.push(val); }); Drafty.attachments(msg, (val) => {
if (val.ref) {
attachments.push(val.ref);
}
});
} }
} }
msg = topic.createMessage(msg, false, mimeType, attachments); msg = topic.createMessage(msg, false, mimeType, attachments);
msg._uploader = uploader; msg._uploader = uploader;
@@ -4829,6 +4840,7 @@ class TinodeWeb extends React.Component {
} }
promise = promise.then(() => { return topic.subscribe(); }); promise = promise.then(() => { return topic.subscribe(); });
} }
topic.publishDraft(msg, promise) topic.publishDraft(msg, promise)
.catch((err) => { .catch((err) => {
this.handleError(err.message, "err"); this.handleError(err.message, "err");