From 0f4dc5c0725ca92179b556a0cff4831a5d20d20d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 3 Jun 2017 15:10:05 +0100 Subject: [PATCH 01/24] first iter of manual update control Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.js | 13 +++++++------ src/components/structures/MatrixChat.js | 5 +++++ src/components/structures/UserSettings.js | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index e2fdeb4687..f42c752bb9 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -182,6 +182,7 @@ export default React.createClass({ const MatrixToolbar = sdk.getComponent('globals.MatrixToolbar'); const GuestWarningBar = sdk.getComponent('globals.GuestWarningBar'); const NewVersionBar = sdk.getComponent('globals.NewVersionBar'); + const UpdateCheckBar = sdk.getComponent('globals.UpdateCheckBar'); let page_element; let right_panel = ''; @@ -249,16 +250,16 @@ export default React.createClass({ break; } - var topBar; + let topBar; if (this.props.hasNewVersion) { topBar = ; - } - else if (this.props.matrixClient.isGuest()) { + } else if (this.props.checkingForUpdate) { + topBar = ; + } else if (this.props.matrixClient.isGuest()) { topBar = ; - } - else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) { + } else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) { topBar = ; } diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 0dedc02270..706f7d35dd 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -127,6 +127,7 @@ module.exports = React.createClass({ newVersion: null, hasNewVersion: false, newVersionReleaseNotes: null, + checkingForUpdate: false, // The username to default to when upgrading an account from a guest upgradeUsername: null, @@ -527,6 +528,9 @@ module.exports = React.createClass({ payload.releaseNotes, ); break; + case 'check_updates': + this.setState({ checkingForUpdate: payload.value }); + break; } }, @@ -1107,6 +1111,7 @@ module.exports = React.createClass({ newVersion: latest, hasNewVersion: current !== latest, newVersionReleaseNotes: releaseNotes, + checkingForUpdate: false, }); }, diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 89debcb461..e914f64859 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -854,6 +854,27 @@ module.exports = React.createClass({ ; }, + _onCheckUpdates: function() { + dis.dispatch({ + action: 'check_updates', + value: true, + }); + }, + + _renderCheckUpdate: function() { + const platform = PlatformPeg.get(); + if ('canSelfUpdate' in platform && platform.canSelfUpdate()) { + return
+

Updates

+
+ + Check for update + +
+
; + } + }, + _renderBulkOptions: function() { const invitedRooms = MatrixClientPeg.get().getRooms().filter((r) => { return r.hasMembershipState(this._me, "invite"); @@ -1246,6 +1267,8 @@ module.exports = React.createClass({ + {this._renderCheckUpdate()} + {this._renderClearCache()} {this._renderDeactivateAccount()} From 98e99d542b6bdbd0818ba9d92512dee93571b254 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 3 Jun 2017 15:48:33 +0100 Subject: [PATCH 02/24] i18n things Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 6 +++--- src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index e914f64859..5af1ed42c6 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -865,10 +865,10 @@ module.exports = React.createClass({ const platform = PlatformPeg.get(); if ('canSelfUpdate' in platform && platform.canSelfUpdate()) { return
-

Updates

+

{_t('Updates')}

- - Check for update + + {_t('Check for update')}
; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 92c6b74444..b9f3c6b36d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -822,6 +822,8 @@ "Online": "Online", "Idle": "Idle", "Offline": "Offline", + "Updates": "Updates", + "Check for update": "Check for update", "Disable URL previews for this room (affects only you)": "Disable URL previews for this room (affects only you)", "$senderDisplayName changed the room avatar to ": "$senderDisplayName changed the room avatar to ", "%(senderDisplayName)s removed the room avatar.": "%(senderDisplayName)s removed the room avatar.", From 6ead97c7a6979bda915dc09aae23924b22f639b3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 11 Jun 2017 19:12:40 +0100 Subject: [PATCH 03/24] change interface to UpdateCheckBar and change launching mechanism Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/LoggedInView.js | 2 +- src/components/structures/MatrixChat.js | 4 ++-- src/components/structures/UserSettings.js | 11 ++--------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index f42c752bb9..f916e28024 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -256,7 +256,7 @@ export default React.createClass({ releaseNotes={this.props.newVersionReleaseNotes} />; } else if (this.props.checkingForUpdate) { - topBar = ; + topBar = ; } else if (this.props.matrixClient.isGuest()) { topBar = ; } else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) { diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 706f7d35dd..6294201e13 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -127,7 +127,7 @@ module.exports = React.createClass({ newVersion: null, hasNewVersion: false, newVersionReleaseNotes: null, - checkingForUpdate: false, + checkingForUpdate: null, // The username to default to when upgrading an account from a guest upgradeUsername: null, @@ -1111,7 +1111,7 @@ module.exports = React.createClass({ newVersion: latest, hasNewVersion: current !== latest, newVersionReleaseNotes: releaseNotes, - checkingForUpdate: false, + checkingForUpdate: null, }); }, diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 5af1ed42c6..a2d9df4900 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -854,20 +854,13 @@ module.exports = React.createClass({ ; }, - _onCheckUpdates: function() { - dis.dispatch({ - action: 'check_updates', - value: true, - }); - }, - _renderCheckUpdate: function() { const platform = PlatformPeg.get(); - if ('canSelfUpdate' in platform && platform.canSelfUpdate()) { + if ('canSelfUpdate' in platform && platform.canSelfUpdate() && 'startUpdateCheck' in platform) { return

{_t('Updates')}

- + {_t('Check for update')}
From ccad1013a71161df34870346d8292b43425979ce Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 11 Jun 2017 23:42:22 +0100 Subject: [PATCH 04/24] don't return null in case it breaks things Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 52e2c7b0e4..7edeafe889 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -863,6 +863,7 @@ module.exports = React.createClass({
; } + return
; }, _renderBulkOptions: function() { From 5460b0f5b2fb963d5a7c44a9fbf1df177ae33be1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jun 2017 15:31:12 +0100 Subject: [PATCH 05/24] reset page subtitle on_logged_out Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index ab937c07ac..21c76fb70f 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -968,6 +968,7 @@ module.exports = React.createClass({ * Called when the session is logged out */ _onLoggedOut: function() { + this._setPageSubtitle(); this.notifyNewScreen('login'); this.setStateForNewScreen({ loggedIn: false, @@ -1267,6 +1268,10 @@ module.exports = React.createClass({ }); }, + _setPageSubtitle: function(subtitle='') { + document.title = `Riot ${subtitle}`; + }, + updateStatusIndicator: function(state, prevState) { let notifCount = 0; @@ -1287,15 +1292,15 @@ module.exports = React.createClass({ PlatformPeg.get().setNotificationCount(notifCount); } - let title = "Riot "; + let subtitle = ''; if (state === "ERROR") { - title += `[${_t("Offline")}] `; + subtitle += `[${_t("Offline")}] `; } if (notifCount > 0) { - title += `[${notifCount}]`; + subtitle += `[${notifCount}]`; } - document.title = title; + this._setPageSubtitle(subtitle); }, onUserSettingsClose: function() { From 2c2091438e6c4d2dee4c5d25d37e2f2621f43d16 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 20 Jun 2017 15:46:54 +0100 Subject: [PATCH 06/24] 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 b712a15a149b95b874c4922250c9c79e48d7aca4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jun 2017 16:15:42 +0100 Subject: [PATCH 07/24] move in case it is racey ---- somehow? Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 108a94cba2..17df3172df 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -993,7 +993,6 @@ module.exports = React.createClass({ * Called when the session is logged out */ _onLoggedOut: function() { - this._setPageSubtitle(); this.notifyNewScreen('login'); this.setStateForNewView({ view: VIEWS.LOGIN, @@ -1004,6 +1003,7 @@ module.exports = React.createClass({ page_type: PageTypes.RoomDirectory, }); this._teamToken = null; + this._setPageSubtitle(); }, /** From 3320df4cdd8d2af88e5da277bc2d976225c07b50 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 20 Jun 2017 17:11:17 +0100 Subject: [PATCH 08/24] Don't allow UserSettings to render if !MatrixClientPeg.get() Now that it has state that updates following the nulling of the MCP (userHasGeneratedPassword) we need to stop it from rendering if the MCP is null. Fixes https://github.com/vector-im/riot-web/issues/4319 --- src/components/structures/UserSettings.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 686e63cd75..c4cc60f077 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -276,6 +276,16 @@ module.exports = React.createClass({ } }, + // `UserSettings` assumes that the client peg will not be null, so give it some + // sort of assurance here by only allowing a re-render if the client is truthy. + // + // This is required because `UserSettings` maintains its own state and if this state + // updates (e.g. during _setStateFromSessionStore) after the client peg has been made + // null (during logout), then it will attempt to re-render and throw errors. + shouldComponentUpdate: function() { + return Boolean(MatrixClientPeg.get()); + }, + _setStateFromSessionStore: function() { this.setState({ userHasGeneratedPassword: Boolean(this._sessionStore.getCachedPassword()), 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 09/24] 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) { From 36d10e7bb68bfb38aac13d25184f1244e3606d6d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jun 2017 18:47:35 +0100 Subject: [PATCH 10/24] move favicon reset stuff here where its more general Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/BasePlatform.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index d0d8e0c74e..e45f4a57b9 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -17,6 +17,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +import dis from 'dispatcher'; + /** * Base class for classes that provide platform-specific functionality * eg. Setting an application badge or displaying notifications @@ -27,6 +29,16 @@ export default class BasePlatform { constructor() { this.notificationCount = 0; this.errorDidOccur = false; + + dis.register(this._onAction.bind(this)); + } + + _onAction(payload: Object) { + switch (payload.action) { + case 'on_logged_out': + this.setNotificationCount(0); + break; + } } // Used primarily for Analytics From a5fffe4afa8367b6522036eb7a144a5ad506157a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@googlemail.com> Date: Tue, 20 Jun 2017 20:15:25 +0100 Subject: [PATCH 11/24] fix ambiguity --- src/BasePlatform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BasePlatform.js b/src/BasePlatform.js index e45f4a57b9..a920479823 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -17,7 +17,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import dis from 'dispatcher'; +import dis from './dispatcher'; /** * Base class for classes that provide platform-specific functionality From 9ef9d09d44548c066b0186b87eeac2015922dc7f Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Jun 2017 11:27:18 +0100 Subject: [PATCH 12/24] Fix another race with first-sync Set the first sync variables in onWillStartClient, as they race if set on logged in (similar fix to https://github.com/matrix-org/matrix-react-sdk/pull/1124) --- src/components/structures/MatrixChat.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 87799640bd..4b85ae1722 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -942,10 +942,6 @@ module.exports = React.createClass({ dis.dispatch({action: 'view_home_page'}); } else if (this._is_registered) { this._is_registered = false; - // reset the 'have completed first sync' flag, - // since we've just logged in and will be about to sync - this.firstSyncComplete = false; - this.firstSyncPromise = q.defer(); // Set the display name = user ID localpart MatrixClientPeg.get().setDisplayName( @@ -1015,6 +1011,12 @@ module.exports = React.createClass({ // Set ready to false now, then it'll be set to true when the sync // listener we set below fires. this.setState({ready: false}); + + // reset the 'have completed first sync' flag, + // since we're about to start the client and therefore about + // to do the first sync + this.firstSyncComplete = false; + this.firstSyncPromise = q.defer(); const cli = MatrixClientPeg.get(); // Allow the JS SDK to reap timeline events. This reduces the amount of From e193fa5be5f128a7ee0fb83d877992ce9cfe9013 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Jun 2017 14:04:43 +0100 Subject: [PATCH 13/24] Make the indexeddb worker script work again Removed in https://github.com/matrix-org/matrix-react-sdk/commit/939f6d07984cd51241357a5e61bf76bd46179fcf --- src/MatrixClientPeg.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 03716be2da..307e65e861 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2017 Vector Creations Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -129,7 +130,7 @@ class MatrixClientPeg { timelineSupport: true, }; - this.matrixClient = createMatrixClient(opts); + this.matrixClient = createMatrixClient(opts, this.indexedDbWorkerScript); // we're going to add eventlisteners for each matrix event tile, so the // potential number of event listeners is quite high. From a62f6d109431eeddea55043fca06fb4819c9942a Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Jun 2017 14:04:43 +0100 Subject: [PATCH 14/24] Make the indexeddb worker script work again Removed in https://github.com/matrix-org/matrix-react-sdk/commit/939f6d07984cd51241357a5e61bf76bd46179fcf --- src/MatrixClientPeg.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 47370e2142..ba372add13 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2017 Vector Creations Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -127,7 +128,7 @@ class MatrixClientPeg { timelineSupport: true, }; - this.matrixClient = createMatrixClient(opts); + this.matrixClient = createMatrixClient(opts, this.indexedDbWorkerScript); // we're going to add eventlisteners for each matrix event tile, so the // potential number of event listeners is quite high. From 2db24f373ce0a568047e25fddd4206f18e551528 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Jun 2017 11:27:18 +0100 Subject: [PATCH 15/24] Fix another race with first-sync Set the first sync variables in onWillStartClient, as they race if set on logged in (similar fix to https://github.com/matrix-org/matrix-react-sdk/pull/1124) --- src/components/structures/MatrixChat.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index e5aefdf665..39a8225b8a 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -919,10 +919,6 @@ module.exports = React.createClass({ dis.dispatch({action: 'view_home_page'}); } else if (this._is_registered) { this._is_registered = false; - // reset the 'have completed first sync' flag, - // since we've just logged in and will be about to sync - this.firstSyncComplete = false; - this.firstSyncPromise = q.defer(); // Set the display name = user ID localpart MatrixClientPeg.get().setDisplayName( @@ -992,6 +988,12 @@ module.exports = React.createClass({ // Set ready to false now, then it'll be set to true when the sync // listener we set below fires. this.setState({ready: false}); + + // reset the 'have completed first sync' flag, + // since we're about to start the client and therefore about + // to do the first sync + this.firstSyncComplete = false; + this.firstSyncPromise = q.defer(); const cli = MatrixClientPeg.get(); // Allow the JS SDK to reap timeline events. This reduces the amount of From dcd0103acb8198fddfb3b7262b8c406729ddc137 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 20 Jun 2017 15:46:54 +0100 Subject: [PATCH 16/24] 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 e9ab667d292dade3233e5bb35b04fc4ee4c5b158 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 21 Jun 2017 17:43:34 +0100 Subject: [PATCH 17/24] Use the web worker when clearing js-sdk stores It turns out that Firefox doesn't let you use indexeddb from private tabs, *unless* you are *also* in a webworker. We need to either consistently use it or not use it - so let's use it. --- src/MatrixClientPeg.js | 3 +-- src/utils/createMatrixClient.js | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index ba372add13..774a1e598c 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -48,7 +48,6 @@ class MatrixClientPeg { this.opts = { initialSyncLimit: 20, }; - this.indexedDbWorkerScript = null; } /** @@ -59,7 +58,7 @@ class MatrixClientPeg { * @param {string} script href to the script to be passed to the web worker */ setIndexedDbWorkerScript(script) { - this.indexedDbWorkerScript = script; + createMatrixClient.indexedDbWorkerScript = script; } get(): MatrixClient { diff --git a/src/utils/createMatrixClient.js b/src/utils/createMatrixClient.js index 5effd63f2a..b95a9f111f 100644 --- a/src/utils/createMatrixClient.js +++ b/src/utils/createMatrixClient.js @@ -25,13 +25,13 @@ const localStorage = window.localStorage; * @param {Object} opts options to pass to Matrix.createClient. This will be * extended with `sessionStore` and `store` members. * - * @param {string} indexedDbWorkerScript Optional URL for a web worker script - * for IndexedDB store operations. If not given, indexeddb ops are done on + * @property {string} indexedDbWorkerScript Optional URL for a web worker script + * for IndexedDB store operations. By default, indexeddb ops are done on * the main thread. * * @returns {MatrixClient} the newly-created MatrixClient */ -export default function createMatrixClient(opts, indexedDbWorkerScript) { +export default function createMatrixClient(opts) { const storeOpts = {}; if (localStorage) { @@ -45,7 +45,7 @@ export default function createMatrixClient(opts, indexedDbWorkerScript) { indexedDB: window.indexedDB, dbName: "riot-web-sync", localStorage: localStorage, - workerScript: indexedDbWorkerScript, + workerScript: createMatrixClient.indexedDbWorkerScript, }); } @@ -53,3 +53,5 @@ export default function createMatrixClient(opts, indexedDbWorkerScript) { return Matrix.createClient(opts); } + +createMatrixClient.indexedDbWorkerScript = null; From efc5cf28893c79847b97fed8f99c9ad91d1e0109 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 21 Jun 2017 21:49:41 +0100 Subject: [PATCH 18/24] Remove dead special-casing for OLM.BAD_LEGACY_ACCOUNT_PICKLE We used to show a special error message when we got this error; however https://github.com/matrix-org/matrix-react-sdk/pull/783 made that not work. You'll only hit it if you're upgrading from some ancient version of Olm, and I'm quite happy for us to fall back to the generic 'couldn't restore: vape your storage?' flow in that case. (In any case that's preferable to dumping you at the login prompt with no warning that we've just vaped your storage). --- src/Lifecycle.js | 18 +----------------- src/i18n/strings/de_DE.json | 1 - src/i18n/strings/el.json | 1 - src/i18n/strings/en_EN.json | 1 - src/i18n/strings/en_US.json | 1 - src/i18n/strings/fr.json | 1 - src/i18n/strings/hu.json | 1 - src/i18n/strings/pt.json | 1 - src/i18n/strings/pt_BR.json | 1 - src/i18n/strings/ru.json | 1 - 10 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 424c58249c..06f5d9ef00 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -29,7 +29,6 @@ import DMRoomMap from './utils/DMRoomMap'; import RtsClient from './RtsClient'; import Modal from './Modal'; import sdk from './index'; -import { _t } from './languageHandler'; /** * Called at startup, to attempt to build a logged-in Matrix session. It tries @@ -237,27 +236,12 @@ function _restoreFromLocalStorage() { function _handleRestoreFailure(e) { console.log("Unable to restore session", e); - let msg = e.message; - if (msg == "OLM.BAD_LEGACY_ACCOUNT_PICKLE") { - msg = _t( - 'You need to log back in to generate end-to-end encryption keys' - + ' for this device and submit the public key to your homeserver.' - + ' This is a once off; sorry for the inconvenience.', - ); - - _clearStorage(); - - return q.reject(new Error( - _t('Unable to restore previous session') + ': ' + msg, - )); - } - const def = q.defer(); const SessionRestoreErrorDialog = sdk.getComponent('views.dialogs.SessionRestoreErrorDialog'); Modal.createDialog(SessionRestoreErrorDialog, { - error: msg, + error: e.message, onFinished: (success) => { def.resolve(success); }, diff --git a/src/i18n/strings/de_DE.json b/src/i18n/strings/de_DE.json index a99671402b..f328c364ce 100644 --- a/src/i18n/strings/de_DE.json +++ b/src/i18n/strings/de_DE.json @@ -305,7 +305,6 @@ "You are already in a call.": "Du bist bereits in einem Gespräch.", "You cannot place a call with yourself.": "Du kannst keinen Anruf mit dir selbst starten.", "You cannot place VoIP calls in this browser.": "VoIP-Gespräche werden von diesem Browser nicht unterstützt.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "Du musst dich erneut anmelden, um Ende-zu-Ende-Verschlüsselungs-Schlüssel für dieses Gerät zu generieren und um den öffentlichen Schlüssel auf deinem Homeserver zu hinterlegen. Dies muss nur einmal durchgeführt werden, bitte entschuldige die Unannehmlichkeiten.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Deine E-Mail-Adresse scheint nicht mit einer Matrix-ID auf diesem Heimserver verbunden zu sein.", "Sun": "So", "Mon": "Mo", diff --git a/src/i18n/strings/el.json b/src/i18n/strings/el.json index 4e09fd7f2a..6ca1fafc29 100644 --- a/src/i18n/strings/el.json +++ b/src/i18n/strings/el.json @@ -861,7 +861,6 @@ "since the point in time of selecting this option": "από το χρονικό σημείο επιλογής αυτής της ρύθμισης", "The signing key you provided matches the signing key you received from %(userId)s's device %(deviceId)s. Device marked as verified.": "Το κλειδί υπογραφής που δώσατε αντιστοιχεί στο κλειδί υπογραφής που λάβατε από τη συσκευή %(userId)s %(deviceId)s. Η συσκευή έχει επισημανθεί ως επιβεβαιωμένη.", "To link to a room it must have an address.": "Για να συνδεθείτε σε ένα δωμάτιο πρέπει να έχετε μια διεύθυνση.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "Πρέπει να συνδεθείτε ξανά για να δημιουργήσετε τα κλειδιά κρυπτογράφησης από άκρο σε άκρο για αυτήν τη συσκευή και να υποβάλετε το δημόσιο κλειδί στον διακομιστή σας. Αυτό θα χρειαστεί να γίνει μόνο μια φορά.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Η διεύθυνση ηλεκτρονικής αλληλογραφίας σας δεν φαίνεται να συσχετίζεται με Matrix ID σε αυτόν τον διακομιστή.", "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them": "Ο κωδικός πρόσβασής σας άλλαξε επιτυχώς. Δεν θα λάβετε ειδοποιήσεις push σε άλλες συσκευές μέχρι να συνδεθείτε ξανά σε αυτές", "You will not be able to undo this change as you are promoting the user to have the same power level as yourself.": "Δεν θα μπορέσετε να αναιρέσετε αυτήν την αλλαγή καθώς προωθείτε τον χρήστη να έχει το ίδιο επίπεδο δύναμης με τον εαυτό σας.", diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 6334c797e8..7eb8beeafd 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -668,7 +668,6 @@ "You need to be able to invite users to do that.": "You need to be able to invite users to do that.", "You need to be logged in.": "You need to be logged in.", "You need to enter a user name.": "You need to enter a user name.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Your email address does not appear to be associated with a Matrix ID on this Homeserver.", "Your password has been reset": "Your password has been reset", "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them": "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them", diff --git a/src/i18n/strings/en_US.json b/src/i18n/strings/en_US.json index 5233111065..e060add84f 100644 --- a/src/i18n/strings/en_US.json +++ b/src/i18n/strings/en_US.json @@ -601,7 +601,6 @@ "You need to be able to invite users to do that.": "You need to be able to invite users to do that.", "You need to be logged in.": "You need to be logged in.", "You need to enter a user name.": "You need to enter a user name.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a one-off; sorry for the inconvenience.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Your email address does not appear to be associated with a Matrix ID on this Homeserver.", "Your password has been reset": "Your password has been reset", "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them": "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them", diff --git a/src/i18n/strings/fr.json b/src/i18n/strings/fr.json index 039198f0cf..5ba39d730b 100644 --- a/src/i18n/strings/fr.json +++ b/src/i18n/strings/fr.json @@ -566,7 +566,6 @@ "You need to be able to invite users to do that.": "Vous devez être capable d’inviter des utilisateurs pour faire ça.", "You need to be logged in.": "Vous devez être connecté.", "You need to enter a user name.": "Vous devez entrer un nom d’utilisateur.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "Vous devez vous connecter à nouveau pour générer les clés d’encryption pour cet appareil, et soumettre la clé publique à votre homeserver. Cette action ne se reproduira pas ; veuillez nous excuser pour la gêne occasionnée.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Votre adresse e-mail ne semble pas associée à un identifiant Matrix sur ce homeserver.", "Your password has been reset": "Votre mot de passe a été réinitialisé", "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them": "Votre mot de passe a été mis à jour avec succès. Vous ne recevrez plus de notification sur vos appareils jusqu’à ce que vous vous identifiez à nouveau", diff --git a/src/i18n/strings/hu.json b/src/i18n/strings/hu.json index f2fa3bb63e..6b0d03900c 100644 --- a/src/i18n/strings/hu.json +++ b/src/i18n/strings/hu.json @@ -675,7 +675,6 @@ "You need to be able to invite users to do that.": "Hogy ezt csinálhasd meg kell tudnod hívni felhasználókat.", "You need to be logged in.": "Be kell jelentkezz.", "You need to enter a user name.": "Be kell írnod a felhasználói nevet.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "Ahhoz, hogy kulcsot tudjál készíteni a végponttól végpontig való titkosításhoz ehhez az eszközhöz és elküld a kulcsot a egyéni szerverhez vissza kell jelentkezned. Ez egyszeri alkalom, elnézést a kellemetlenségér.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Ez az e-mail cím, úgy néz ki, nincs összekötve a Matrix azonosítóval ezen az egyedi szerveren.", "Your password has been reset": "A jelszavad visszaállítottuk", "Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them": "A jelszavadat sikeresen megváltoztattuk. Nem kapsz \"push\" értesítéseket amíg a többi eszközön vissza nem jelentkezel" diff --git a/src/i18n/strings/pt.json b/src/i18n/strings/pt.json index a8dd8758d4..d48f1a914f 100644 --- a/src/i18n/strings/pt.json +++ b/src/i18n/strings/pt.json @@ -404,7 +404,6 @@ "You cannot place VoIP calls in this browser.": "Você não pode fazer chamadas de voz neste navegador.", "You need to be able to invite users to do that.": "Para fazer isso, você tem que ter permissão para convidar outras pessoas.", "You need to be logged in.": "Você tem que estar logado.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "É necessário que você faça login novamente para poder gerar as chaves de criptografia ponta-a-ponta para este dispositivo e então enviar sua chave pública para o servidor. Pedimos desculpas pela inconveniência, é preciso fazer isso apenas única uma vez.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "O seu endereço de email não parece estar associado a uma conta de usuária/o Matrix neste servidor.", "Set a display name:": "Defina um nome público para você:", "Upload an avatar:": "Envie uma imagem de perfil para identificar você:", diff --git a/src/i18n/strings/pt_BR.json b/src/i18n/strings/pt_BR.json index 1e915a5491..0dc732ebaa 100644 --- a/src/i18n/strings/pt_BR.json +++ b/src/i18n/strings/pt_BR.json @@ -405,7 +405,6 @@ "You cannot place VoIP calls in this browser.": "Você não pode fazer chamadas de voz neste navegador.", "You need to be able to invite users to do that.": "Para fazer isso, você tem que ter permissão para convidar outras pessoas.", "You need to be logged in.": "Você tem que estar logado.", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "É necessário que você faça login novamente para poder gerar as chaves de criptografia ponta-a-ponta para este dispositivo e então enviar sua chave pública para o servidor. Pedimos desculpas pela inconveniência, é preciso fazer isso apenas única uma vez.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "O seu endereço de email não parece estar associado a uma conta de usuária/o Matrix neste servidor.", "Set a display name:": "Defina um nome público para você:", "Upload an avatar:": "Envie uma imagem de perfil para identificar você:", diff --git a/src/i18n/strings/ru.json b/src/i18n/strings/ru.json index 6b6eadf928..30daf9d807 100644 --- a/src/i18n/strings/ru.json +++ b/src/i18n/strings/ru.json @@ -385,7 +385,6 @@ "Thu": "Чт", "Fri": "Пя", "Sat": "Сб", - "You need to log back in to generate end-to-end encryption keys for this device and submit the public key to your homeserver. This is a once off; sorry for the inconvenience.": "Вам необходимо снова войти в генерировать сквозное шифрование (е2е) ключей для этого устройства и предоставить публичный ключ Вашему домашнему серверу. Это после выключения; приносим извинения за причиненные неудобства.", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Ваш адрес электронной почты, кажется, не связан с Matrix ID на этом Homeserver.", "to start a chat with someone": "Начать чат с кем-то", "to tag direct chat": "отметить прямой чат", From 6881fdf1025e735411e3a65fb77cb15118531a5c Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Jun 2017 11:52:13 +0100 Subject: [PATCH 19/24] js-sdk 0.7.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f49fc04661..5d6aebe52f 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "isomorphic-fetch": "^2.2.1", "linkifyjs": "^2.1.3", "lodash": "^4.13.1", - "matrix-js-sdk": "0.7.12", + "matrix-js-sdk": "0.7.13", "optimist": "^0.6.1", "prop-types": "^15.5.8", "q": "^1.4.1", From 5700c179252b20a5cd4e87f776f69a8818f7258e Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Jun 2017 11:57:27 +0100 Subject: [PATCH 20/24] Prepare changelog for v0.9.7 --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22049b6af6..8bc4bbcfce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +Changes in [0.9.7](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.9.7) (2017-06-22) +=================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.9.6...v0.9.7) + + * Fix ability to invite users with caps in their user IDs + [\#1128](https://github.com/matrix-org/matrix-react-sdk/pull/1128) + * Fix another race with first-sync + [\#1131](https://github.com/matrix-org/matrix-react-sdk/pull/1131) + * Make the indexeddb worker script work again + [\#1132](https://github.com/matrix-org/matrix-react-sdk/pull/1132) + * Use the web worker when clearing js-sdk stores + [\#1133](https://github.com/matrix-org/matrix-react-sdk/pull/1133) + Changes in [0.9.6](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.9.6) (2017-06-20) =================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.9.5...v0.9.6) From f7aad3c422f83459cf4657ce260d4bf050d30c4b Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Jun 2017 11:57:27 +0100 Subject: [PATCH 21/24] v0.9.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d6aebe52f..cbc06c9771 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "0.9.6", + "version": "0.9.7", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": { From b124ac21fd9bc79119148f57314c557e53e7e507 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 22 Jun 2017 15:07:54 +0100 Subject: [PATCH 22/24] Fix load failure in firefox when indexedDB is disabled --- src/utils/createMatrixClient.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/utils/createMatrixClient.js b/src/utils/createMatrixClient.js index b95a9f111f..2d294e262b 100644 --- a/src/utils/createMatrixClient.js +++ b/src/utils/createMatrixClient.js @@ -18,6 +18,13 @@ import Matrix from 'matrix-js-sdk'; const localStorage = window.localStorage; +// just *accessing* indexedDB throws an exception in firefox with +// indexeddb disabled. +let indexedDB; +try { + indexedDB = window.indexedDB; +} catch(e) {} + /** * Create a new matrix client, with the persistent stores set up appropriately * (using localstorage/indexeddb, etc) @@ -37,12 +44,13 @@ export default function createMatrixClient(opts) { if (localStorage) { storeOpts.sessionStore = new Matrix.WebStorageSessionStore(localStorage); } - if (window.indexedDB && localStorage) { + + if (indexedDB && localStorage) { // FIXME: bodge to remove old database. Remove this after a few weeks. - window.indexedDB.deleteDatabase("matrix-js-sdk:default"); + indexedDB.deleteDatabase("matrix-js-sdk:default"); storeOpts.store = new Matrix.IndexedDBStore({ - indexedDB: window.indexedDB, + indexedDB: indexedDB, dbName: "riot-web-sync", localStorage: localStorage, workerScript: createMatrixClient.indexedDbWorkerScript, From fcd945afc2e9c563a8f20c5bac3d7cffff6078ca Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 22 Jun 2017 15:08:30 +0100 Subject: [PATCH 23/24] Fix an incorrect console error ... this error is thrown when registering as guest or loading from localstorage, not when using tokenparams. --- src/components/structures/MatrixChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 019446ae84..7773f4f38c 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(`Error attempting to load session from token params: ${e}`); + console.error(`Error attempting to load session: ${e}`); return false; }).then((loadedSession) => { if (!loadedSession) { From a22f14e9101fb91dc619d1506611aeb2c33a3019 Mon Sep 17 00:00:00 2001 From: turt2live Date: Thu, 22 Jun 2017 08:53:58 -0600 Subject: [PATCH 24/24] Use 12h timestamps when enabled in RR Fixes vector-im/riot-web#4393 Signed-off-by: Travis Ralston --- src/DateUtils.js | 6 +++--- src/components/views/rooms/EventTile.js | 1 + src/components/views/rooms/ReadReceiptMarker.js | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/DateUtils.js b/src/DateUtils.js index 0bce7c8a16..545d92dd3b 100644 --- a/src/DateUtils.js +++ b/src/DateUtils.js @@ -60,7 +60,7 @@ function twelveHourTime(date) { } module.exports = { - formatDate: function(date) { + formatDate: function(date, showTwelveHour=false) { var now = new Date(); const days = getDaysArray(); const months = getMonthsArray(); @@ -69,7 +69,7 @@ module.exports = { } else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) { // TODO: use standard date localize function provided in counterpart - return _t('%(weekDayName)s %(time)s', {weekDayName: days[date.getDay()], time: this.formatTime(date)}); + return _t('%(weekDayName)s %(time)s', {weekDayName: days[date.getDay()], time: this.formatTime(date, showTwelveHour)}); } else if (now.getFullYear() === date.getFullYear()) { // TODO: use standard date localize function provided in counterpart @@ -80,7 +80,7 @@ module.exports = { time: this.formatTime(date), }); } - return this.formatFullDate(date); + return this.formatFullDate(date, showTwelveHour); }, formatFullDate: function(date, showTwelveHour=false) { diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 5c970a0966..170925999d 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -336,6 +336,7 @@ module.exports = WithMatrixClient(React.createClass({ suppressAnimation={this._suppressReadReceiptAnimation} onClick={this.toggleAllReadAvatars} timestamp={receipt.ts} + showTwelveHour={this.props.isTwelveHour} /> ); } diff --git a/src/components/views/rooms/ReadReceiptMarker.js b/src/components/views/rooms/ReadReceiptMarker.js index 7565b0741d..64b54fe1e1 100644 --- a/src/components/views/rooms/ReadReceiptMarker.js +++ b/src/components/views/rooms/ReadReceiptMarker.js @@ -66,6 +66,9 @@ module.exports = React.createClass({ // Timestamp when the receipt was read timestamp: React.PropTypes.number, + + // True to show twelve hour format, false otherwise + showTwelveHour: React.PropTypes.bool, }, getDefaultProps: function() { @@ -172,7 +175,7 @@ module.exports = React.createClass({ if (this.props.timestamp) { title = _t( "Seen by %(userName)s at %(dateTime)s", - {userName: this.props.member.userId, dateTime: DateUtils.formatDate(new Date(this.props.timestamp))} + {userName: this.props.member.userId, dateTime: DateUtils.formatDate(new Date(this.props.timestamp), this.props.showTwelveHour)} ); }