From cf1b1442ebad3ea14349c3b4c4bf78728f598d32 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 17 Sep 2016 14:29:40 +0100 Subject: [PATCH] no labs for guests --- src/UserSettingsStore.js | 3 +++ src/components/structures/UserSettings.js | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index aa55c6a258..845e81de36 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -160,6 +160,9 @@ module.exports = { }, isFeatureEnabled: function(feature: string): boolean { + // Disable labs for guests. + if (MatrixClientPeg.get().isGuest()) return false; + if (localStorage.getItem(`mx_labs_feature_${feature}`) === null) { for (var i = 0; i < this.LABS_FEATURES.length; i++) { var f = this.LABS_FEATURES[i]; diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 61f544ea99..6836987823 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -369,6 +369,16 @@ module.exports = React.createClass({ name={feature.id} defaultChecked={ UserSettingsStore.isFeatureEnabled(feature.id) } onChange={e => { + if (MatrixClientPeg.get().isGuest()) { + e.target.checked = false; + var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog"); + Modal.createDialog(NeedToRegisterDialog, { + title: "Please Register", + description: "Guests can't use labs features. Please register.", + }); + return; + } + UserSettingsStore.setFeatureEnabled(feature.id, e.target.checked); this.forceUpdate(); }}/>