From d2684638b4b842ef2daed3fb9d47254e23de8d25 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 23 Jan 2019 17:58:11 -0700 Subject: [PATCH] Actually include the lazy loading function --- .../views/settings/tabs/LabsSettingsTab.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/components/views/settings/tabs/LabsSettingsTab.js b/src/components/views/settings/tabs/LabsSettingsTab.js index 5cda8f6cd6..2686ce6591 100644 --- a/src/components/views/settings/tabs/LabsSettingsTab.js +++ b/src/components/views/settings/tabs/LabsSettingsTab.js @@ -19,12 +19,38 @@ import {_t} from "../../../../languageHandler"; import PropTypes from "prop-types"; import SettingsStore from "../../../../settings/SettingsStore"; import ToggleSwitch from "../../elements/ToggleSwitch"; +const Modal = require("../../../../Modal"); +const sdk = require("../../../../index"); export class LabsSettingToggle extends React.Component { static propTypes = { featureId: PropTypes.string.isRequired, }; + async _onLazyLoadChanging(enabling) { + // don't prevent turning LL off when not supported + if (enabling) { + const supported = await MatrixClientPeg.get().doesServerSupportLazyLoading(); + if (!supported) { + await new Promise((resolve) => { + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + 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; + } + } + return true; + } + _onChange = async (checked) => { if (this.props.featureId === "feature_lazyloading") { const confirmed = await this._onLazyLoadChanging(checked);