From 2c2091438e6c4d2dee4c5d25d37e2f2621f43d16 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 20 Jun 2017 15:46:54 +0100 Subject: [PATCH 1/2] Fix ability to invite users with caps in their user IDs By lowercasing only when testing against local user IDs/display names. The user_directory shouldn't care. And when we make the placeholder "We didn't get any results, but here's the user with the exact mxid you typed in", use the original query. --- src/components/views/dialogs/ChatInviteDialog.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index 9a14cb91d3..a85efadef7 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -178,7 +178,7 @@ module.exports = React.createClass({ }, onQueryChanged: function(ev) { - const query = ev.target.value.toLowerCase(); + const query = ev.target.value; if (this.queryChangedDebouncer) { clearTimeout(this.queryChangedDebouncer); } @@ -271,10 +271,11 @@ module.exports = React.createClass({ query, searchError: null, }); + const queryLowercase = query.toLowerCase(); const results = []; MatrixClientPeg.get().getUsers().forEach((user) => { - if (user.userId.toLowerCase().indexOf(query) === -1 && - user.displayName.toLowerCase().indexOf(query) === -1 + if (user.userId.toLowerCase().indexOf(queryLowercase) === -1 && + user.displayName.toLowerCase().indexOf(queryLowercase) === -1 ) { return; } From cd73139af5769f99c6776fe24258dceee8f1c781 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 20 Jun 2017 17:38:02 +0100 Subject: [PATCH 2/2] Various logging cleanups * don't just log errors without any context as to where they came from or what they mean * avoid the use of '%s' and multi-argument console.log because it looks awful under karma. --- src/Lifecycle.js | 16 ++++++++-------- src/MatrixClientPeg.js | 4 +++- src/components/structures/MatrixChat.js | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 59580e7cb6..424c58249c 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -156,7 +156,7 @@ export function attemptTokenLogin(queryParams, defaultDeviceDisplayName) { } function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) { - console.log("Doing guest login on %s", hsUrl); + console.log(`Doing guest login on ${hsUrl}`); // TODO: we should probably de-duplicate this and Login.loginAsGuest. // Not really sure where the right home for it is. @@ -171,7 +171,7 @@ function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) { initial_device_display_name: defaultDeviceDisplayName, }, }).then((creds) => { - console.log("Registered as guest: %s", creds.user_id); + console.log(`Registered as guest: ${creds.user_id}`); return _doSetLoggedIn({ userId: creds.user_id, deviceId: creds.device_id, @@ -215,7 +215,7 @@ function _restoreFromLocalStorage() { } if (accessToken && userId && hsUrl) { - console.log("Restoring session for %s", userId); + console.log(`Restoring session for ${userId}`); try { return _doSetLoggedIn({ userId: userId, @@ -315,10 +315,10 @@ async function _doSetLoggedIn(credentials, clearStorage) { credentials.guest = Boolean(credentials.guest); console.log( - "setLoggedIn: mxid:", credentials.userId, - "deviceId:", credentials.deviceId, - "guest:", credentials.guest, - "hs:", credentials.homeserverUrl, + "setLoggedIn: mxid: " + credentials.userId + + " deviceId: " + credentials.deviceId + + " guest: " + credentials.guest + + " hs: " + credentials.homeserverUrl, ); // This is dispatched to indicate that the user is still in the process of logging in @@ -395,7 +395,7 @@ function _persistCredentialsToLocalStorage(credentials) { localStorage.setItem("mx_device_id", credentials.deviceId); } - console.log("Session persisted for %s", credentials.userId); + console.log(`Session persisted for ${credentials.userId}`); } /** diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 47370e2142..03716be2da 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -84,7 +84,9 @@ class MatrixClientPeg { let promise = this.matrixClient.store.startup(); // log any errors when starting up the database (if one exists) - promise.catch((err) => { console.error(err); }); + promise.catch((err) => { + console.error(`Error starting matrixclient store: ${err}`); + }); // regardless of errors, start the client. If we did error out, we'll // just end up doing a full initial /sync. diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 97a0962741..87799640bd 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -330,7 +330,7 @@ module.exports = React.createClass({ defaultDeviceDisplayName: this.props.defaultDeviceDisplayName, }); }).catch((e) => { - console.error("Unable to load session", e); + console.error(`Error attempting to load session from token params: ${e}`); return false; }).then((loadedSession) => { if (!loadedSession) {