From 04a46226cbb4a4a7786fb462974e86988bdfb9b9 Mon Sep 17 00:00:00 2001 From: Krille Date: Sun, 15 Dec 2024 12:21:26 +0100 Subject: [PATCH] refactor: Fix new lints from flutter 3.27 --- lib/encryption/utils/json_signature_check_extension.dart | 4 +++- .../msc_3814_dehydrated_devices.dart | 4 +++- lib/src/client.dart | 4 +++- lib/src/models/receipts.dart | 4 +++- lib/src/room.dart | 4 +++- lib/src/timeline.dart | 8 ++++++-- lib/src/utils/event_localizations.dart | 1 - lib/src/utils/pushrule_evaluator.dart | 1 - lib/src/voip/backend/mesh_backend.dart | 1 - lib/src/voip/call_session.dart | 4 +++- 10 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/encryption/utils/json_signature_check_extension.dart b/lib/encryption/utils/json_signature_check_extension.dart index f53cdad9..7c1f4f6c 100644 --- a/lib/encryption/utils/json_signature_check_extension.dart +++ b/lib/encryption/utils/json_signature_check_extension.dart @@ -27,7 +27,9 @@ extension JsonSignatureCheckExtension on Map { final signatures = this['signatures']; if (signatures == null || signatures is! Map || - !signatures.containsKey(userId)) return false; + !signatures.containsKey(userId)) { + return false; + } remove('unsigned'); remove('signatures'); if (!signatures[userId].containsKey('ed25519:$deviceId')) return false; diff --git a/lib/msc_extensions/msc_3814_dehydrated_devices/msc_3814_dehydrated_devices.dart b/lib/msc_extensions/msc_3814_dehydrated_devices/msc_3814_dehydrated_devices.dart index cc102b80..e53c1915 100644 --- a/lib/msc_extensions/msc_3814_dehydrated_devices/msc_3814_dehydrated_devices.dart +++ b/lib/msc_extensions/msc_3814_dehydrated_devices/msc_3814_dehydrated_devices.dart @@ -54,7 +54,9 @@ extension DehydratedDeviceHandler on Client { // Only handle devices we understand // In the future we might want to migrate to a newer format here if (device.deviceData?.tryGet('algorithm') != - _dehydratedDeviceAlgorithm) return; + _dehydratedDeviceAlgorithm) { + return; + } // Verify that the device is cross-signed final dehydratedDeviceIdentity = diff --git a/lib/src/client.dart b/lib/src/client.dart index ed52269c..bf38bdde 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -2567,7 +2567,9 @@ class Client extends MatrixApi { if (event.event.roomID != roomId) continue; if (!sessionIds.contains( event.event.content['content']?['session_id'], - )) continue; + )) { + continue; + } final decryptedEvent = await event.event.decrypt(room); if (decryptedEvent.content.tryGet('type') != diff --git a/lib/src/models/receipts.dart b/lib/src/models/receipts.dart index 9bb3e3c6..d7027c43 100644 --- a/lib/src/models/receipts.dart +++ b/lib/src/models/receipts.dart @@ -115,7 +115,9 @@ class ReceiptEventContent { if (userId is! String || !userId.isValidMatrixId || - receiptContent is! Map) continue; + receiptContent is! Map) { + continue; + } final ts = receiptContent['ts']; final threadId = receiptContent['thread_id']; diff --git a/lib/src/room.dart b/lib/src/room.dart index 420dced0..a94dc586 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -518,7 +518,9 @@ class Room { // There is no known event or the last event is only a state fallback event, // we assume there is no new messages. if (lastEvent == null || - !client.roomPreviewLastEvents.contains(lastEvent.type)) return false; + !client.roomPreviewLastEvents.contains(lastEvent.type)) { + return false; + } // Read marker is on the last event so no new messages. if (lastEvent.receipts diff --git a/lib/src/timeline.dart b/lib/src/timeline.dart index 801b743d..55949fa0 100644 --- a/lib/src/timeline.dart +++ b/lib/src/timeline.dart @@ -263,7 +263,9 @@ class Timeline { if (!allowNewEvent) { if (resp.start == resp.end || - (resp.end == null && direction == Direction.f)) allowNewEvent = true; + (resp.end == null && direction == Direction.f)) { + allowNewEvent = true; + } if (allowNewEvent) { Logs().d('We now allow sync update into the timeline.'); @@ -566,7 +568,9 @@ class Timeline { events.indexWhere( (e) => e.eventId == eventUpdate.content['event_id'], ) != - -1) return; + -1) { + return; + } var index = events.length; if (eventUpdate.type == EventUpdateType.history) { events.add(newEvent); diff --git a/lib/src/utils/event_localizations.dart b/lib/src/utils/event_localizations.dart index e03b9d0c..1ae3b98a 100644 --- a/lib/src/utils/event_localizations.dart +++ b/lib/src/utils/event_localizations.dart @@ -203,7 +203,6 @@ abstract class EventLocalizations { case RoomMemberChangeType.knock: return i18n.hasKnocked(targetName); case RoomMemberChangeType.other: - default: return userIsTarget ? i18n.youJoinedTheChat : i18n.joinedTheChat(targetName); diff --git a/lib/src/utils/pushrule_evaluator.dart b/lib/src/utils/pushrule_evaluator.dart index f36f560c..9851d121 100644 --- a/lib/src/utils/pushrule_evaluator.dart +++ b/lib/src/utils/pushrule_evaluator.dart @@ -153,7 +153,6 @@ class _MemberCountCondition { case _CountComparisonOp.lt: return memberCount < count; case _CountComparisonOp.eq: - default: return memberCount == count; } } diff --git a/lib/src/voip/backend/mesh_backend.dart b/lib/src/voip/backend/mesh_backend.dart index 0e0245b4..fd45a52d 100644 --- a/lib/src/voip/backend/mesh_backend.dart +++ b/lib/src/voip/backend/mesh_backend.dart @@ -650,7 +650,6 @@ class MeshBackend extends CallBackend { await call.setLocalVideoMuted(muted); } break; - default: } } diff --git a/lib/src/voip/call_session.dart b/lib/src/voip/call_session.dart index c11dbf30..a809de1f 100644 --- a/lib/src/voip/call_session.dart +++ b/lib/src/voip/call_session.dart @@ -1016,7 +1016,9 @@ class CallSession { // when a call crash and this call is already terminated the currentCId is null. // So don't return bc the hangup or reject will not proceed anymore. if (voip.currentCID != null && - voip.currentCID != VoipId(roomId: room.id, callId: callId)) return; + voip.currentCID != VoipId(roomId: room.id, callId: callId)) { + return; + } voip.currentCID = null; voip.incomingCallRoomId.removeWhere((key, value) => value == callId); }