From 84b74247e625cc7bbab36db7caca38a18db403b4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 13 Aug 2018 16:19:44 +0200 Subject: [PATCH] check if server supports lazy loading before enabling --- src/components/structures/UserSettings.js | 28 +++++++++++++++++++---- src/i18n/strings/en_EN.json | 4 +++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index a5ba4ff0fa..157540f183 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -847,7 +847,7 @@ module.exports = React.createClass({ const onChange = async (e) => { const checked = e.target.checked; if (featureId === "feature_lazyloading") { - const confirmed = await this._onLazyLoadChanging(); + const confirmed = await this._onLazyLoadChanging(checked); if (!confirmed) { e.preventDefault(); return; @@ -886,9 +886,28 @@ module.exports = React.createClass({ ); }, - _onLazyLoadChanging: function() { - return new Promise((resolve) => { - const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + _onLazyLoadChanging: async function(enabling) { + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + // don't prevent turning LL off when not supported + if (enabling) { + const supported = await MatrixClientPeg.get().doesServerSupportLazyLoading(); + if (!supported) { + await new Promise((resolve) => { + Modal.createDialog(QuestionDialog, { + title: _t("Lazy loading members not supported"), + description: +
+ { _t("Lazy loading is not supported by your " + + "current homeserver.") } +
, + button: _t("OK"), + onFinished: resolve, + }); + }); + return false; + } + } + const confirmed = await new Promise((resolve) => { Modal.createDialog(QuestionDialog, { title: _t("Turn on/off lazy load members"), description: @@ -909,6 +928,7 @@ module.exports = React.createClass({ onFinished: resolve, }); }); + return confirmed; }, _renderDeactivateAccount: function() { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index f1f056f58e..eb05ff36e7 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1220,5 +1220,7 @@ "Increase performance by only loading room members on first view": "Increase performance by only loading room members on first view", "Turn on/off lazy load members": "Turn on/off lazy load members", "To enable or disable the lazy loading of members, the current synced state needs to be cleared out. This also includes your end-to-end encryption keys, so to keep being able to decrypt all your existing encrypted messages, you'll need to export your E2E room keys and import them again afterwards.": "To enable or disable the lazy loading of members, the current synced state needs to be cleared out. This also includes your end-to-end encryption keys, so to keep being able to decrypt all your existing encrypted messages, you'll need to export your E2E room keys and import them again afterwards.", - "Clear sync state and reload": "Clear sync state and reload" + "Clear sync state and reload": "Clear sync state and reload", + "Lazy loading members not supported": "Lazy load members not supported", + "Lazy loading is not supported by your current homeserver.": "Lazy loading is not supported by your current homeserver." }