implement PR feedback, move LL dialog to UserSettings
parent
3731431e59
commit
28292c3388
|
@ -845,7 +845,15 @@ module.exports = React.createClass({
|
||||||
// TODO: this ought to be a separate component so that we don't need
|
// TODO: this ought to be a separate component so that we don't need
|
||||||
// to rebind the onChange each time we render
|
// to rebind the onChange each time we render
|
||||||
const onChange = async (e) => {
|
const onChange = async (e) => {
|
||||||
await SettingsStore.setFeatureEnabled(featureId, e.target.checked);
|
const checked = e.target.checked;
|
||||||
|
if (featureId === "feature_lazyloading") {
|
||||||
|
const confirmed = await this._onLazyLoadChanging();
|
||||||
|
if (!confirmed) {
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await SettingsStore.setFeatureEnabled(featureId, checked);
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -878,6 +886,31 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onLazyLoadChanging: function() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
||||||
|
Modal.createDialog(QuestionDialog, {
|
||||||
|
title: _t("Turn on/off lazy load members"),
|
||||||
|
description:
|
||||||
|
<div>
|
||||||
|
{ _t("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.") }
|
||||||
|
</div>,
|
||||||
|
button: _t("Clear sync state and reload"),
|
||||||
|
extraButtons: [
|
||||||
|
<button key="export" className="mx_Dialog_primary"
|
||||||
|
onClick={this._onExportE2eKeysClicked}>
|
||||||
|
{ _t("Export E2E room keys") }
|
||||||
|
</button>,
|
||||||
|
],
|
||||||
|
onFinished: resolve,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
_renderDeactivateAccount: function() {
|
_renderDeactivateAccount: function() {
|
||||||
return <div>
|
return <div>
|
||||||
<h3>{ _t("Deactivate Account") }</h3>
|
<h3>{ _t("Deactivate Account") }</h3>
|
||||||
|
|
|
@ -275,21 +275,12 @@ export default class SettingsStore {
|
||||||
throw new Error("User cannot set " + settingName + " at " + level + " in " + roomId);
|
throw new Error("User cannot set " + settingName + " at " + level + " in " + roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const controller = SETTINGS[settingName].controller;
|
|
||||||
if (controller) {
|
|
||||||
const changeAllowed = await controller.canChangeTo(level, roomId, value);
|
|
||||||
if (!changeAllowed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await handler.setValue(settingName, roomId, value);
|
await handler.setValue(settingName, roomId, value);
|
||||||
|
|
||||||
|
const controller = SETTINGS[settingName].controller;
|
||||||
if (controller) {
|
if (controller) {
|
||||||
controller.onChange(level, roomId, value);
|
controller.onChange(level, roomId, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,41 +26,4 @@ export default class LazyLoadingController extends SettingController {
|
||||||
onChange(level, roomId, newValue) {
|
onChange(level, roomId, newValue) {
|
||||||
dis.dispatch({action: 'flush_storage_reload'});
|
dis.dispatch({action: 'flush_storage_reload'});
|
||||||
}
|
}
|
||||||
|
|
||||||
canChangeTo(level, roomId, newValue) {
|
|
||||||
return new Promise((resolve) => this._showReloadDialog(resolve));
|
|
||||||
}
|
|
||||||
|
|
||||||
_showReloadDialog(onFinished) {
|
|
||||||
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
|
||||||
Modal.createDialog(QuestionDialog, {
|
|
||||||
title: _t("Turn on/off lazy load members"),
|
|
||||||
description:
|
|
||||||
<div>
|
|
||||||
{ _t("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.") }
|
|
||||||
</div>,
|
|
||||||
button: _t("Clear sync state and reload"),
|
|
||||||
extraButtons: [
|
|
||||||
<button key="export" className="mx_Dialog_primary"
|
|
||||||
onClick={this._onExportE2eKeysClicked}>
|
|
||||||
{ _t("Export E2E room keys") }
|
|
||||||
</button>,
|
|
||||||
],
|
|
||||||
onFinished,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_onExportE2eKeysClicked() {
|
|
||||||
Modal.createTrackedDialogAsync('Export E2E Keys', '', (cb) => {
|
|
||||||
require.ensure(['../../async-components/views/dialogs/ExportE2eKeysDialog'], () => {
|
|
||||||
cb(require('../../async-components/views/dialogs/ExportE2eKeysDialog'));
|
|
||||||
}, "e2e-export");
|
|
||||||
}, {
|
|
||||||
matrixClient: MatrixClientPeg.get(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,6 @@ export default class SettingController {
|
||||||
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
|
getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) {
|
||||||
return null; // no override
|
return null; // no override
|
||||||
}
|
}
|
||||||
|
|
||||||
canChangeTo(level, roomId, newValue) {
|
|
||||||
return Promise.resolve(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the setting value has been changed.
|
* Called when the setting value has been changed.
|
||||||
* @param {string} level The level at which the setting has been modified.
|
* @param {string} level The level at which the setting has been modified.
|
||||||
|
|
Loading…
Reference in New Issue