From 7d78233bf08a11b53738272bbeb48b1da07e6594 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 28 Oct 2021 14:40:02 +0200 Subject: [PATCH] refactor: remove literal boolean comparisons leftover from nullsafety conversion --- lib/encryption/key_verification_manager.dart | 4 ++-- lib/encryption/olm_manager.dart | 5 ++--- lib/encryption/utils/key_verification.dart | 12 ++++-------- lib/src/client.dart | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/encryption/key_verification_manager.dart b/lib/encryption/key_verification_manager.dart index 319f780e..2b1dbfb2 100644 --- a/lib/encryption/key_verification_manager.dart +++ b/lib/encryption/key_verification_manager.dart @@ -56,7 +56,7 @@ class KeyVerificationManager { Future handleToDeviceEvent(ToDeviceEvent event) async { if (!event.type.startsWith('m.key.verification.') || - client.verificationMethods.isEmpty != false) { + client.verificationMethods.isEmpty) { return; } // we have key verification going on! @@ -95,7 +95,7 @@ class KeyVerificationManager { : event['content']['msgtype']; if (type == null || !type.startsWith('m.key.verification.') || - client.verificationMethods.isEmpty != false) { + client.verificationMethods.isEmpty) { return; } if (type == EventTypes.KeyVerificationRequest) { diff --git a/lib/encryption/olm_manager.dart b/lib/encryption/olm_manager.dart index a99a1b6d..52eca0f9 100644 --- a/lib/encryption/olm_manager.dart +++ b/lib/encryption/olm_manager.dart @@ -57,8 +57,7 @@ class OlmManager { await olm.init(); _olmAccount = olm.Account(); _olmAccount!.create(); - if (await uploadKeys(uploadDeviceKeys: true, updateDatabase: false) == - false) { + if (!await uploadKeys(uploadDeviceKeys: true, updateDatabase: false)) { throw ('Upload key failed'); } } catch (_) { @@ -359,7 +358,7 @@ class OlmManager { if (session.session == null) { continue; } - if (type == 0 && session.session!.matches_inbound(body) == true) { + if (type == 0 && session.session!.matches_inbound(body)) { try { plaintext = session.session!.decrypt(type, body); } catch (e) { diff --git a/lib/encryption/utils/key_verification.dart b/lib/encryption/utils/key_verification.dart index 97984fec..d21e9736 100644 --- a/lib/encryption/utils/key_verification.dart +++ b/lib/encryption/utils/key_verification.dart @@ -152,10 +152,8 @@ class KeyVerification { List get knownVerificationMethods { final methods = []; - if (client.verificationMethods.contains(KeyVerificationMethod.numbers) == - true || - client.verificationMethods.contains(KeyVerificationMethod.emoji) == - true) { + if (client.verificationMethods.contains(KeyVerificationMethod.numbers) || + client.verificationMethods.contains(KeyVerificationMethod.emoji)) { methods.add('m.sas.v1'); } return methods; @@ -672,13 +670,11 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod { List get knownAuthentificationTypes { final types = []; if (request.client.verificationMethods - .contains(KeyVerificationMethod.emoji) == - true) { + .contains(KeyVerificationMethod.emoji)) { types.add('emoji'); } if (request.client.verificationMethods - .contains(KeyVerificationMethod.numbers) == - true) { + .contains(KeyVerificationMethod.numbers)) { types.add('decimal'); } return types; diff --git a/lib/src/client.dart b/lib/src/client.dart index bf3393fd..1b680df3 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -464,7 +464,7 @@ class Client extends MatrixApi { @Deprecated('Deprecated in favour of identifier.') String? medium, @Deprecated('Deprecated in favour of identifier.') String? address, }) async { - if (homeserver == null && user != null && user.isValidMatrixId == true) { + if (homeserver == null && user != null && user.isValidMatrixId) { await checkHomeserver(user.domain); } final response = await super.login(