Actually include the lazy loading function

pull/21833/head
Travis Ralston 2019-01-23 17:58:11 -07:00
parent f1c1caac62
commit d2684638b4
1 changed files with 26 additions and 0 deletions

View File

@ -19,12 +19,38 @@ import {_t} from "../../../../languageHandler";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import SettingsStore from "../../../../settings/SettingsStore"; import SettingsStore from "../../../../settings/SettingsStore";
import ToggleSwitch from "../../elements/ToggleSwitch"; import ToggleSwitch from "../../elements/ToggleSwitch";
const Modal = require("../../../../Modal");
const sdk = require("../../../../index");
export class LabsSettingToggle extends React.Component { export class LabsSettingToggle extends React.Component {
static propTypes = { static propTypes = {
featureId: PropTypes.string.isRequired, 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:
<div>
{ _t("Lazy loading is not supported by your " +
"current homeserver.") }
</div>,
button: _t("OK"),
onFinished: resolve,
});
});
return false;
}
}
return true;
}
_onChange = async (checked) => { _onChange = async (checked) => {
if (this.props.featureId === "feature_lazyloading") { if (this.props.featureId === "feature_lazyloading") {
const confirmed = await this._onLazyLoadChanging(checked); const confirmed = await this._onLazyLoadChanging(checked);