minor corrections

This commit is contained in:
or-else
2018-03-17 18:57:10 -07:00
parent 95b9f1a1fd
commit 9283c4ede2
+12 -10
View File
@@ -1015,13 +1015,13 @@
<form id="login-form" onSubmit={this.handleSubmit}> <form id="login-form" onSubmit={this.handleSubmit}>
<input type="text" id="inputLogin" <input type="text" id="inputLogin"
placeholder="Login (alice, bob, carol, dave, frank)" placeholder="Login (alice, bob, carol, dave, frank)"
autocomplete="username" autoComplete="username"
value={this.state.login} value={this.state.login}
onChange={this.handleLoginChange} onChange={this.handleLoginChange}
required autoFocus /> required autoFocus />
<input type="password" id="inputPassword" <input type="password" id="inputPassword"
placeholder="Password (alice123, bob123, ...)" placeholder="Password (alice123, bob123, ...)"
autocomplete="current-password" autoComplete="current-password"
value={this.state.password} value={this.state.password}
onChange={this.handlePasswordChange} onChange={this.handlePasswordChange}
required /> required />
@@ -1786,6 +1786,11 @@
}, this); }, this);
updateFavicon(totalUnread > 0); updateFavicon(totalUnread > 0);
// Sort: most recent to less recent.
//contacts.sort(function(a, b) {
// return a.updated - b.updated;
//});
return contacts; return contacts;
}, },
@@ -2211,8 +2216,11 @@
}, },
handleSubmit: function(e) { handleSubmit: function(e) {
e.preventDefault(); e.preventDefault();
if (this.state.groupId && this.state.groupId.trim()) { if (this.state.groupId) {
this.props.onSubmit(this.state.groupId.trim()); var name = this.state.groupId.trim();
if (name.length > 3 && (name.substr(0, 3) == 'usr' || name.substr(0, 3) == 'grp')) {
this.props.onSubmit(name);
}
} }
}, },
render: function() { render: function() {
@@ -3591,18 +3599,12 @@
}, },
doLogin: function(login, password, cred) { doLogin: function(login, password, cred) {
console.log("doLogin", login, password, cred);
var instance = this; var instance = this;
cred = cred ? Tinode.addCredential(null, cred.type, null, null, cred.resp).cred : undefined; cred = cred ? Tinode.addCredential(null, cred.type, null, null, cred.resp).cred : undefined;
console.log("doLogin cred=", cred);
// Try to login with token. If token is not available, try password. If no password, ask for it. // Try to login with token. If token is not available, try password. If no password, ask for it.
var promise = null; var promise = null;
var token = Tinode.getLoginToken(); var token = Tinode.getLoginToken();
console.log("doLogin token=", token);
if (token) { if (token) {
promise = Tinode.loginToken(token.token, cred); promise = Tinode.loginToken(token.token, cred);
} else if (password) { } else if (password) {