From 3958e3267219111d8fa005a607d05ba23e438890 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sat, 4 Nov 2017 20:13:23 -0700 Subject: [PATCH] Ensure blacklistUnverifiedDevices persists reloads Signed-off-by: Travis Ralston --- src/Lifecycle.js | 4 ++++ src/components/structures/MatrixChat.js | 28 ++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 4d8911f7a6..946f22537d 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -436,6 +436,10 @@ function startMatrixClient() { DMRoomMap.makeShared().start(); MatrixClientPeg.start(); + + // dispatch that we finished starting up to wire up any other bits + // of the matrix client that cannot be set prior to starting up. + dis.dispatch({action: 'client_started'}); } /* diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index f76201fa55..ec959a5c61 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -43,7 +43,7 @@ import createRoom from "../../createRoom"; import * as UDEHandler from '../../UnknownDeviceErrorHandler'; import KeyRequestHandler from '../../KeyRequestHandler'; import { _t, getCurrentLanguage } from '../../languageHandler'; -import SettingsStore from "../../settings/SettingsStore"; +import SettingsStore, {SettingLevel} from "../../settings/SettingsStore"; /** constants for MatrixChat.state.view */ const VIEWS = { @@ -566,6 +566,9 @@ module.exports = React.createClass({ this._onWillStartClient(); }); break; + case 'client_started': + this._onClientStarted(); + break; case 'new_version': this.onVersion( payload.currentVersion, payload.newVersion, @@ -1092,6 +1095,29 @@ module.exports = React.createClass({ cli.on("crypto.roomKeyRequestCancellation", (req) => { krh.handleKeyRequestCancellation(req); }); + cli.on("Room", (room) => { + const blacklistEnabled = SettingsStore.getValueAt( + SettingLevel.ROOM_DEVICE, + "blacklistUnverifiedDevices", + room.roomId, + ); + room.setBlacklistUnverifiedDevices(blacklistEnabled); + }); + }, + + /** + * Called shortly after the matrix client has started. Useful for + * setting up anything that requires the client to be started. + * @private + */ + _onClientStarted: function() { + const cli = MatrixClientPeg.get(); + + const blacklistEnabled = SettingsStore.getValueAt( + SettingLevel.DEVICE, + "blacklistUnverifiedDevices" + ); + cli.setGlobalBlacklistUnverifiedDevices(blacklistEnabled); }, showScreen: function(screen, params) {