conversion to react 16 seems to be successful

This commit is contained in:
or-else
2018-07-27 19:27:26 +03:00
parent a542afd194
commit 2f8e5c4b33
+17 -3
View File
@@ -818,10 +818,12 @@
class HostSelector extends React.PureComponent { class HostSelector extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
hostName: props.serverAddress, hostName: props.serverAddress,
changed: false changed: false
}; };
this.handleHostNameChange = this.handleHostNameChange.bind(this); this.handleHostNameChange = this.handleHostNameChange.bind(this);
this.handleEditingFinished = this.handleEditingFinished.bind(this); this.handleEditingFinished = this.handleEditingFinished.bind(this);
} }
@@ -863,6 +865,7 @@
class CheckBox extends React.PureComponent { class CheckBox extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
} }
@@ -1175,6 +1178,8 @@
/* BEGIN GroupSubs: a list of group subscribers currently online */ /* BEGIN GroupSubs: a list of group subscribers currently online */
class GroupSubs extends React.Component { class GroupSubs extends React.Component {
constructor(props) { constructor(props) {
super(props);
this.state = { this.state = {
onlineSubs: props.subscribers || [] onlineSubs: props.subscribers || []
}; };
@@ -1186,7 +1191,7 @@
render() { render() {
var usersOnline = []; var usersOnline = [];
this.state.onlineSubs.map(function(sub) { this.state.onlineSubs.map((sub) => {
usersOnline.push( usersOnline.push(
<div className="avatar-box"> <div className="avatar-box">
<LetterTile <LetterTile
@@ -1286,6 +1291,7 @@
class CreateAccountView extends React.PureComponent { class CreateAccountView extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
login: '', login: '',
password: '', password: '',
@@ -1296,6 +1302,7 @@
errorCleared: false, errorCleared: false,
saveToken: localStorage.getObject("keep-logged-in") saveToken: localStorage.getObject("keep-logged-in")
}; };
this.handleLoginChange = this.handleLoginChange.bind(this); this.handleLoginChange = this.handleLoginChange.bind(this);
this.handlePasswordChange = this.handlePasswordChange.bind(this); this.handlePasswordChange = this.handlePasswordChange.bind(this);
this.handlePassword2Change = this.handlePassword2Change.bind(this); this.handlePassword2Change = this.handlePassword2Change.bind(this);
@@ -4409,6 +4416,7 @@
foundContacts: [], foundContacts: [],
credMethod: '' credMethod: ''
}; };
this.handleResize = this.handleResize.bind(this); this.handleResize = this.handleResize.bind(this);
this.handleHashRoute = this.handleHashRoute.bind(this); this.handleHashRoute = this.handleHashRoute.bind(this);
this.handleOnline = this.handleOnline.bind(this); this.handleOnline = this.handleOnline.bind(this);
@@ -4495,6 +4503,12 @@
this.readTimerCallback = null; this.readTimerCallback = null;
} }
componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
window.removeEventListener('hashchange', this.handleHashRoute);
document.removeEventListener("visibilitychange", this.handleVisibilityEvent);
}
// Setup transport (usually websocket) and server address. This will terminate connection with the server. // Setup transport (usually websocket) and server address. This will terminate connection with the server.
// FIXME: make static // FIXME: make static
tnSetup(serverAddress, transport) { tnSetup(serverAddress, transport) {
@@ -4630,13 +4644,13 @@
var instance = this; var instance = this;
if (promise) { if (promise) {
promise.then(function(ctrl) { promise.then((ctrl) => {
if (ctrl.code >= 300 && ctrl.text === "validate credentials") { if (ctrl.code >= 300 && ctrl.text === "validate credentials") {
instance.handleCredentialsRequest(ctrl.params); instance.handleCredentialsRequest(ctrl.params);
} else { } else {
instance.handleLoginSuccessful(instance); instance.handleLoginSuccessful(instance);
} }
}).catch(function(err) { }).catch((err) => {
// Login failed, report error // Login failed, report error
instance.setState({loginDisabled: false}); instance.setState({loginDisabled: false});
instance.handleError(err.message, "err"); instance.handleError(err.message, "err");