From 824ad5e318d9193390e00b235dbe3e0cd41960da Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 26 Sep 2018 16:25:21 +0100 Subject: [PATCH 1/5] delete sync data when LL is toggled, show message when enabling --- src/Lifecycle.js | 22 +++++++++++++ .../views/dialogs/LazyLoadingResyncDialog.js | 32 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/components/views/dialogs/LazyLoadingResyncDialog.js diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 795489c1faa..517040ebb26 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -31,6 +31,7 @@ import RtsClient from './RtsClient'; import Modal from './Modal'; import sdk from './index'; import ActiveWidgetStore from './stores/ActiveWidgetStore'; +import PlatformPeg from "./PlatformPeg"; /** * Called at startup, to attempt to build a logged-in Matrix session. It tries @@ -237,6 +238,27 @@ async function _restoreFromLocalStorage() { function _handleLoadSessionFailure(e) { console.log("Unable to load session", e); + if (e instanceof Matrix.InvalidStoreError) { + if (e.reason === Matrix.InvalidStoreError.TOGGLED_LAZY_LOADING) { + const LazyLoadingResyncDialog = + sdk.getComponent("views.dialogs.LazyLoadingResyncDialog"); + return Promise.resolve().then(() => { + const lazyLoadEnabled = e.value; + if (lazyLoadEnabled) { + return new Promise((resolve) => { + Modal.createDialog(LazyLoadingResyncDialog, { + onFinished: resolve, + }); + }); + } + }).then(() => { + return MatrixClientPeg.get().store.deleteAllData(); + }).then(() => { + PlatformPeg.get().reload(); + }); + } + } + const def = Promise.defer(); const SessionRestoreErrorDialog = sdk.getComponent('views.dialogs.SessionRestoreErrorDialog'); diff --git a/src/components/views/dialogs/LazyLoadingResyncDialog.js b/src/components/views/dialogs/LazyLoadingResyncDialog.js new file mode 100644 index 00000000000..97684f670b8 --- /dev/null +++ b/src/components/views/dialogs/LazyLoadingResyncDialog.js @@ -0,0 +1,32 @@ +/* +Copyright 2015, 2016 OpenMarket Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import React from 'react'; +import QuestionDialog from './QuestionDialog'; +import { _t } from '../../../languageHandler'; + +export default (props) => { + const description = + _t("Lazy loading has been enabled for your account. Performance!! We'll need to resync your account."); + + return ({description}} + button={_t("OK")} + onFinished={props.onFinished} + />); +}; From 130f3cc2ff8bbc57d20c7a230537d9a5e2731bcc Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 26 Sep 2018 16:30:35 +0100 Subject: [PATCH 2/5] only get component when needed --- src/Lifecycle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 517040ebb26..434975a5bc6 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -240,11 +240,11 @@ function _handleLoadSessionFailure(e) { if (e instanceof Matrix.InvalidStoreError) { if (e.reason === Matrix.InvalidStoreError.TOGGLED_LAZY_LOADING) { - const LazyLoadingResyncDialog = - sdk.getComponent("views.dialogs.LazyLoadingResyncDialog"); return Promise.resolve().then(() => { const lazyLoadEnabled = e.value; if (lazyLoadEnabled) { + const LazyLoadingResyncDialog = + sdk.getComponent("views.dialogs.LazyLoadingResyncDialog"); return new Promise((resolve) => { Modal.createDialog(LazyLoadingResyncDialog, { onFinished: resolve, From fd2ab406d4c8b311862654b0084b1cf7bd9bb492 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 26 Sep 2018 16:48:04 +0100 Subject: [PATCH 3/5] update copy --- src/components/views/dialogs/LazyLoadingResyncDialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/LazyLoadingResyncDialog.js b/src/components/views/dialogs/LazyLoadingResyncDialog.js index 97684f670b8..b770de8d13c 100644 --- a/src/components/views/dialogs/LazyLoadingResyncDialog.js +++ b/src/components/views/dialogs/LazyLoadingResyncDialog.js @@ -20,11 +20,11 @@ import { _t } from '../../../languageHandler'; export default (props) => { const description = - _t("Lazy loading has been enabled for your account. Performance!! We'll need to resync your account."); + _t("Riot now uses 3-5x less memory, by only loading information about other users when needed. Please wait whilst we resynchronise with the server!"); return ({description}} button={_t("OK")} onFinished={props.onFinished} From e0c5b0d5ede96757eb63b1c16cfce20068232632 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 26 Sep 2018 17:23:51 +0100 Subject: [PATCH 4/5] translations --- src/i18n/strings/en_EN.json | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index a29de76e69b..94dc3cb3938 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -174,6 +174,13 @@ "%(senderDisplayName)s removed the room name.": "%(senderDisplayName)s removed the room name.", "%(senderDisplayName)s changed the room name to %(roomName)s.": "%(senderDisplayName)s changed the room name to %(roomName)s.", "%(senderDisplayName)s sent an image.": "%(senderDisplayName)s sent an image.", + "%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|other": "%(senderName)s added %(addedAddresses)s as addresses for this room.", + "%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|one": "%(senderName)s added %(addedAddresses)s as an address for this room.", + "%(senderName)s removed %(count)s %(removedAddresses)s as addresses for this room.|other": "%(senderName)s removed %(removedAddresses)s as addresses for this room.", + "%(senderName)s removed %(count)s %(removedAddresses)s as addresses for this room.|one": "%(senderName)s removed %(removedAddresses)s as an address for this room.", + "%(senderName)s added %(addedAddresses)s and removed %(removedAddresses)s as addresses for this room.": "%(senderName)s added %(addedAddresses)s and removed %(removedAddresses)s as addresses for this room.", + "%(senderName)s set the main address for this room to %(address)s.": "%(senderName)s set the main address for this room to %(address)s.", + "%(senderName)s removed the main address for this room.": "%(senderName)s removed the main address for this room.", "Someone": "Someone", "(not supported by this browser)": "(not supported by this browser)", "%(senderName)s answered the call.": "%(senderName)s answered the call.", @@ -877,6 +884,8 @@ "Ignore request": "Ignore request", "Loading device info...": "Loading device info...", "Encryption key request": "Encryption key request", + "Riot now uses 3-5x less memory, by only loading information about other users when needed. Please wait whilst we resynchronise with the server!": "Riot now uses 3-5x less memory, by only loading information about other users when needed. Please wait whilst we resynchronise with the server!", + "Updating Riot": "Updating Riot", "Failed to upgrade room": "Failed to upgrade room", "The room upgrade could not be completed": "The room upgrade could not be completed", "Upgrade this room to version %(version)s": "Upgrade this room to version %(version)s", @@ -1246,13 +1255,6 @@ "Import room keys": "Import room keys", "This process allows you to import encryption keys that you had previously exported from another Matrix client. You will then be able to decrypt any messages that the other client could decrypt.": "This process allows you to import encryption keys that you had previously exported from another Matrix client. You will then be able to decrypt any messages that the other client could decrypt.", "The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.": "The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.", - "%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|one": "%(senderName)s added %(addedAddresses)s as an address for this room.", - "%(senderName)s added %(count)s %(addedAddresses)s as addresses for this room.|other": "%(senderName)s added %(addedAddresses)s as addresses for this room.", - "%(senderName)s removed %(count)s %(removedAddresses)s as addresses for this room.|one": "%(senderName)s removed %(removedAddresses)s as an address for this room.", - "%(senderName)s removed %(count)s %(removedAddresses)s as addresses for this room.|other": "%(senderName)s removed %(removedAddresses)s as addresses for this room.", - "%(senderName)s added %(addedAddresses)s and removed %(removedAddresses)s as addresses for this room.": "%(senderName)s added %(addedAddresses)s and removed %(removedAddresses)s as addresses for this room.", - "%(senderName)s set the main address for this room to %(address)s.": "%(senderName)s set the main address for this room to %(address)s.", - "%(senderName)s removed the main address for this room.": "%(senderName)s removed the main address for this room.", "File to import": "File to import", "Import": "Import", "Failed to set direct chat tag": "Failed to set direct chat tag", From f4860cfe6370e30a160ccabce6d7f38dce1b7d86 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 26 Sep 2018 18:22:05 +0100 Subject: [PATCH 5/5] update copyright notice --- src/components/views/dialogs/LazyLoadingResyncDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/LazyLoadingResyncDialog.js b/src/components/views/dialogs/LazyLoadingResyncDialog.js index b770de8d13c..0e6259c84d5 100644 --- a/src/components/views/dialogs/LazyLoadingResyncDialog.js +++ b/src/components/views/dialogs/LazyLoadingResyncDialog.js @@ -1,5 +1,5 @@ /* -Copyright 2015, 2016 OpenMarket Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.