check if server supports lazy loading before enabling

pull/21833/head
Bruno Windels 2018-08-13 16:19:44 +02:00
parent 94c424d3bb
commit 84b74247e6
2 changed files with 27 additions and 5 deletions

View File

@ -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:
<div>
{ _t("Lazy loading is not supported by your " +
"current homeserver.") }
</div>,
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() {

View File

@ -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."
}