From dfa9eda10e92749d62b8d174d8052c7c6d09569b Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Thu, 10 Oct 2024 18:50:49 +0200 Subject: [PATCH] Replace `MatrixClient.setGlobalBlacklistUnverifiedDevices` by `MatrixClient.CryptoApi.globalBlacklistUnverifiedDevices` --- src/components/structures/MatrixChat.tsx | 5 +++-- src/components/views/settings/CryptographyPanel.tsx | 3 ++- test/components/structures/MatrixChat-test.tsx | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 32d3bc7bd6..bbb1b77c9d 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -1707,9 +1707,10 @@ export default class MatrixChat extends React.PureComponent { } } - if (cli.getCrypto()) { + const crypto = cli.getCrypto(); + if (crypto) { const blacklistEnabled = SettingsStore.getValueAt(SettingLevel.DEVICE, "blacklistUnverifiedDevices"); - cli.setGlobalBlacklistUnverifiedDevices(blacklistEnabled); + crypto.globalBlacklistUnverifiedDevices = blacklistEnabled; // With cross-signing enabled, we send to unknown devices // without prompting. Any bad-device status the user should diff --git a/src/components/views/settings/CryptographyPanel.tsx b/src/components/views/settings/CryptographyPanel.tsx index 853a75e6b1..08917d215c 100644 --- a/src/components/views/settings/CryptographyPanel.tsx +++ b/src/components/views/settings/CryptographyPanel.tsx @@ -140,6 +140,7 @@ export default class CryptographyPanel extends React.Component { }; private updateBlacklistDevicesFlag = (checked: boolean): void => { - MatrixClientPeg.safeGet().setGlobalBlacklistUnverifiedDevices(checked); + const crypto = MatrixClientPeg.safeGet().getCrypto(); + if (crypto) crypto.globalBlacklistUnverifiedDevices = checked; }; } diff --git a/test/components/structures/MatrixChat-test.tsx b/test/components/structures/MatrixChat-test.tsx index 4d1f78af97..432494b0e3 100644 --- a/test/components/structures/MatrixChat-test.tsx +++ b/test/components/structures/MatrixChat-test.tsx @@ -125,7 +125,6 @@ describe("", () => { }), getVisibleRooms: jest.fn().mockReturnValue([]), getRooms: jest.fn().mockReturnValue([]), - setGlobalBlacklistUnverifiedDevices: jest.fn(), setGlobalErrorOnUnknownDevices: jest.fn(), getCrypto: jest.fn().mockReturnValue({ getVerificationRequestsToDeviceInProgress: jest.fn().mockReturnValue([]), @@ -135,6 +134,7 @@ describe("", () => { getVersion: jest.fn().mockReturnValue("1"), setDeviceIsolationMode: jest.fn(), userHasCrossSigningKeys: jest.fn(), + globalBlacklistUnverifiedDevices: false, }), // This needs to not finish immediately because we need to test the screen appears bootstrapCrossSigning: jest.fn().mockImplementation(() => bootstrapDeferred.promise),