diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 795489c1faa..434975a5bc6 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) { + 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, + }); + }); + } + }).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..0e6259c84d5 --- /dev/null +++ b/src/components/views/dialogs/LazyLoadingResyncDialog.js @@ -0,0 +1,32 @@ +/* +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. +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("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} + />); +}; 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",