Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit c3a9658

Browse files
committed
Add experimental "Labs" section to settings
1 parent 469c415 commit c3a9658

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/UserSettingsStore.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,14 @@ module.exports = {
112112
append: true, // We always append for email pushers since we don't want to stop other accounts notifying to the same email address
113113
});
114114
},
115+
116+
isFeatureEnabled: function(feature: string): boolean {
117+
feature = feature.match(/\w+/g).join('_').toLowerCase();
118+
return localStorage.getItem(`mx_labs_feature_${feature}`) === 'true';
119+
},
120+
121+
setFeatureEnabled: function(feature: string, enabled: boolean) {
122+
feature = feature.match(/\w+/g).join('_').toLowerCase();
123+
localStorage.setItem(`mx_labs_feature_${feature}`, enabled);
124+
}
115125
};

src/components/structures/UserSettings.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ var GeminiScrollbar = require('react-gemini-scrollbar');
2626
var Email = require('../../email');
2727
var AddThreepid = require('../../AddThreepid');
2828

29+
const LABS_FEATURES = [
30+
'Rich Text Editor',
31+
'End-to-End Encryption'
32+
];
33+
2934
module.exports = React.createClass({
3035
displayName: 'UserSettings',
3136

@@ -357,6 +362,32 @@ module.exports = React.createClass({
357362
</div>);
358363
}
359364

365+
this._renderLabs = function () {
366+
let features = LABS_FEATURES.map(feature => (
367+
<div>
368+
<input key={feature}
369+
type="checkbox"
370+
id={feature}
371+
name={feature}
372+
defaultChecked={UserSettingsStore.isFeatureEnabled(feature)}
373+
onChange={e => UserSettingsStore.setFeatureEnabled(feature, e.target.checked)} />
374+
<label htmlFor={feature}>{feature}</label>
375+
</div>
376+
));
377+
return (
378+
<div>
379+
<h3>Labs</h3>
380+
381+
<div className="mx_UserSettings_section">
382+
<p>These experimental features may change, break or disappear at any time. We make absolutely no guarantees about what may happen if you turn one of these experiments on, and your client may even spontaneously combust. Jokes aside, your client may delete all your data or your security and privacy could be compromised in unexpected ways. Please proceed with caution.</p>
383+
{features}
384+
<br />
385+
<div className="mx_UserSettings_button" onClick={() => window.location.reload()}>Restart Vector</div>
386+
</div>
387+
</div>
388+
)
389+
};
390+
360391
return (
361392
<div className="mx_UserSettings">
362393
<SimpleRoomHeader title="Settings" onCancelClick={ this.props.onClose }/>
@@ -411,6 +442,8 @@ module.exports = React.createClass({
411442

412443
{this._renderDeviceInfo()}
413444

445+
{this._renderLabs()}
446+
414447
<h3>Advanced</h3>
415448

416449
<div className="mx_UserSettings_section">

0 commit comments

Comments
 (0)