Replace MatrixClient.isCryptoEnabled
by MatrixClient.getCrypto
(#140)
* Replace `MatrixClient.isCryptoEnabled` by `MatrixClient.getCrypto` * Cast `cryptoEnabled` as `boolean` * Fix `MatrixChat-test` (cherry picked from commit 950ab1940bfcea9443f03284f9175d319c13a44c)
This commit is contained in:
parent
146968da2c
commit
571ada37a7
14 changed files with 11 additions and 36 deletions
|
@ -413,7 +413,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
|
||||
private async postLoginSetup(): Promise<void> {
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
const cryptoEnabled = cli.isCryptoEnabled();
|
||||
const cryptoEnabled = Boolean(cli.getCrypto());
|
||||
if (!cryptoEnabled) {
|
||||
this.onLoggedIn();
|
||||
}
|
||||
|
@ -1619,7 +1619,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
.catch((e) => logger.error("Unable to start DecryptionFailureTracker", e));
|
||||
|
||||
cli.on(ClientEvent.Room, (room) => {
|
||||
if (cli.isCryptoEnabled()) {
|
||||
if (cli.getCrypto()) {
|
||||
const blacklistEnabled = SettingsStore.getValueAt(
|
||||
SettingLevel.ROOM_DEVICE,
|
||||
"blacklistUnverifiedDevices",
|
||||
|
@ -1707,7 +1707,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
if (cli.isCryptoEnabled()) {
|
||||
if (cli.getCrypto()) {
|
||||
const blacklistEnabled = SettingsStore.getValueAt(SettingLevel.DEVICE, "blacklistUnverifiedDevices");
|
||||
cli.setGlobalBlacklistUnverifiedDevices(blacklistEnabled);
|
||||
|
||||
|
|
|
@ -1461,7 +1461,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
// set the state immediately then update, so we don't scare the user into thinking the room is unencrypted
|
||||
this.setState({ e2eStatus });
|
||||
|
||||
if (this.context.client.isCryptoEnabled()) {
|
||||
if (this.context.client.getCrypto()) {
|
||||
/* At this point, the user has encryption on and cross-signing on */
|
||||
e2eStatus = await shieldStatusForRoom(this.context.client, room);
|
||||
RoomView.e2eStatusCache.set(room.roomId, e2eStatus);
|
||||
|
|
|
@ -265,7 +265,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
public constructor(props: ISendMessageComposerProps, context: React.ContextType<typeof RoomContext>) {
|
||||
super(props, context);
|
||||
|
||||
if (this.props.mxClient.isCryptoEnabled() && this.props.mxClient.isRoomEncrypted(this.props.room.roomId)) {
|
||||
if (this.props.mxClient.getCrypto() && this.props.mxClient.isRoomEncrypted(this.props.room.roomId)) {
|
||||
this.prepareToEncrypt = throttle(
|
||||
() => {
|
||||
this.props.mxClient.getCrypto()?.prepareToEncrypt(this.props.room);
|
||||
|
|
|
@ -15,7 +15,7 @@ export function useEncryptionStatus(client: MatrixClient, room: Room): E2EStatus
|
|||
const [e2eStatus, setE2eStatus] = useState<E2EStatus | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (client.isCryptoEnabled()) {
|
||||
if (client.getCrypto()) {
|
||||
shieldStatusForRoom(client, room).then((e2eStatus) => {
|
||||
setE2eStatus(e2eStatus);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue