From 97d0c41d30b078de587c5c5a79e0da31fc91d1ce Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 29 May 2017 15:08:11 +0100 Subject: [PATCH] fix ugly special casing in generic settings renderer Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 2f8f1ac002..c01a7d2cc7 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -97,6 +97,9 @@ const CRYPTO_SETTINGS_LABELS = [ { id: 'blacklistUnverifiedDevices', label: 'Never send encrypted messages to unverified devices from this device', + fn: function(checked) { + MatrixClientPeg.get().setGlobalBlacklistUnverifiedDevices(checked); + }, }, // XXX: this is here for documentation; the actual setting is managed via RoomSettings // { @@ -600,7 +603,12 @@ module.exports = React.createClass({ UserSettingsStore.setSyncedSetting(setting.id, e.target.checked) } + onChange={ + (e) => { + UserSettingsStore.setSyncedSetting(setting.id, e.target.checked); + if (setting.fn) setting.fn(e.target.checked); + } + } /> { _t(setting.label) } @@ -676,7 +684,6 @@ module.exports = React.createClass({ }, _renderLocalSetting: function(setting) { - const client = MatrixClientPeg.get(); return { UserSettingsStore.setLocalSetting(setting.id, e.target.checked); - if (setting.id === 'blacklistUnverifiedDevices') { // XXX: this is a bit ugly - client.setGlobalBlacklistUnverifiedDevices(e.target.checked); - } + if (setting.fn) setting.fn(e.target.checked); } - } + } /> { _t(setting.label) }