From eb0ff83bc57c94132b87f43d435b0f8bfcc8e7b0 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:59:54 +0000 Subject: [PATCH] Silence some warnings. (#4747) --- .../Mocks/Generated/GeneratedMocks.swift | 4 +- .../HTMLParsing/AttributedStringBuilder.swift | 2 +- ElementX/Sources/Other/SDKListener.swift | 20 +++++++++ .../Sources/Services/Client/ClientProxy.swift | 38 ++++------------- .../ElementCall/CXProviderProtocol.swift | 2 +- .../ElementCall/ElementCallWidgetDriver.swift | 2 +- .../Keychain/KeychainController.swift | 4 +- .../Media/Provider/MediaFileHandleProxy.swift | 2 +- .../Services/Room/JoinedRoomProxy.swift | 42 ++----------------- .../SessionVerificationControllerProxy.swift | 2 +- NSE/Sources/NSEUserSession.swift | 2 +- 11 files changed, 40 insertions(+), 80 deletions(-) diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 39c3e752d..45429530f 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -2141,9 +2141,9 @@ class CXProviderMock: CXProviderProtocol, @unchecked Sendable { } var reportNewIncomingCallWithUpdateCompletionReceivedArguments: (uuid: UUID, update: CXCallUpdate, completion: (Error?) -> Void)? var reportNewIncomingCallWithUpdateCompletionReceivedInvocations: [(uuid: UUID, update: CXCallUpdate, completion: (Error?) -> Void)] = [] - var reportNewIncomingCallWithUpdateCompletionClosure: ((UUID, CXCallUpdate, @escaping (Error?) -> Void) -> Void)? + var reportNewIncomingCallWithUpdateCompletionClosure: ((UUID, CXCallUpdate, @Sendable @escaping (Error?) -> Void) -> Void)? - func reportNewIncomingCall(with uuid: UUID, update: CXCallUpdate, completion: @escaping (Error?) -> Void) { + func reportNewIncomingCall(with uuid: UUID, update: CXCallUpdate, completion: @Sendable @escaping (Error?) -> Void) { reportNewIncomingCallWithUpdateCompletionCallsCount += 1 reportNewIncomingCallWithUpdateCompletionReceivedArguments = (uuid: uuid, update: update, completion: completion) DispatchQueue.main.async { diff --git a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift index e74e616f8..59fa8ec23 100644 --- a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift +++ b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilder.swift @@ -111,7 +111,7 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol { // MARK: - Private - // swiftlint:disable:next function_body_length + // swiftlint:disable:next function_body_length cyclomatic_complexity func attributedString(element: Element, documentBody: Element, preserveFormatting: Bool, diff --git a/ElementX/Sources/Other/SDKListener.swift b/ElementX/Sources/Other/SDKListener.swift index 5ee16f2cf..43c9f13e8 100644 --- a/ElementX/Sources/Other/SDKListener.swift +++ b/ElementX/Sources/Other/SDKListener.swift @@ -51,6 +51,14 @@ extension SDKListener: VerificationStateListener where T == VerificationState { func onUpdate(status: VerificationState) { onUpdateClosure(status) } } +extension SDKListener: IgnoredUsersListener where T == [String] { + func call(ignoredUserIds: [String]) { onUpdateClosure(ignoredUserIds) } +} + +extension SDKListener: SendQueueRoomErrorListener where T == (String, ClientError) { + func onError(roomId: String, error: ClientError) { onUpdateClosure((roomId, error)) } +} + // MARK: SecureBackupController extension SDKListener: BackupStateListener where T == BackupState { @@ -107,6 +115,18 @@ extension SDKListener: CallDeclineListener where T == String { func call(declinerUserId: String) { onUpdateClosure(declinerUserId) } } +extension SDKListener: TypingNotificationsListener where T == [String] { + func call(typingUserIds: [String]) { onUpdateClosure(typingUserIds) } +} + +extension SDKListener: IdentityStatusChangeListener where T == [IdentityStatusChange] { + func call(identityStatusChange: [IdentityStatusChange]) { onUpdateClosure(identityStatusChange) } +} + +extension SDKListener: KnockRequestsListener where T == [KnockRequest] { + func call(joinRequests: [KnockRequest]) { onUpdateClosure(joinRequests) } +} + // MARK: TimelineProxy extension SDKListener: PaginationStatusListener where T == RoomPaginationStatus { diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 82929f775..2c29d41f6 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -6,7 +6,7 @@ // Please see LICENSE files in the repository root for full details. // -import Combine +@preconcurrency import Combine import CryptoKit import Foundation import OrderedCollections @@ -208,7 +208,7 @@ class ClientProxy: ClientProxyProtocol { loadUserAvatarURLFromCache() - ignoredUsersListenerTaskHandle = client.subscribeToIgnoredUsers(listener: IgnoredUsersListenerProxy { [weak self] ignoredUsers in + ignoredUsersListenerTaskHandle = client.subscribeToIgnoredUsers(listener: SDKListener { [weak self] ignoredUsers in self?.ignoredUsersSubject.send(ignoredUsers) }) @@ -218,7 +218,7 @@ class ClientProxy: ClientProxyProtocol { Task { await self?.updateVerificationState(verificationState) } }) - sendQueueListenerTaskHandle = client.subscribeToSendQueueStatus(listener: SendQueueRoomErrorListenerProxy { [weak self] roomID, error in + sendQueueListenerTaskHandle = client.subscribeToSendQueueStatus(listener: SDKListener { [weak self] roomID, error in MXLog.error("Send queue failed in room: \(roomID) with error: \(error)") self?.sendQueueStatusSubject.send(false) }) @@ -1143,10 +1143,10 @@ class ClientProxy: ClientProxyProtocol { } } -private class ClientDelegateWrapper: ClientDelegate { - private let authErrorCallback: (Bool) -> Void +private final class ClientDelegateWrapper: ClientDelegate { + private let authErrorCallback: @Sendable (Bool) -> Void - init(authErrorCallback: @escaping (Bool) -> Void) { + init(authErrorCallback: @escaping @Sendable (Bool) -> Void) { self.authErrorCallback = authErrorCallback } @@ -1162,7 +1162,7 @@ private class ClientDelegateWrapper: ClientDelegate { } } -private class ClientDecryptionErrorDelegate: UnableToDecryptDelegate { +private final class ClientDecryptionErrorDelegate: UnableToDecryptDelegate { private let actionsSubject: PassthroughSubject init(actionsSubject: PassthroughSubject) { @@ -1174,30 +1174,6 @@ private class ClientDecryptionErrorDelegate: UnableToDecryptDelegate { } } -private class IgnoredUsersListenerProxy: IgnoredUsersListener { - private let onUpdateClosure: ([String]) -> Void - - init(onUpdateClosure: @escaping ([String]) -> Void) { - self.onUpdateClosure = onUpdateClosure - } - - func call(ignoredUserIds: [String]) { - onUpdateClosure(ignoredUserIds) - } -} - -private class SendQueueRoomErrorListenerProxy: SendQueueRoomErrorListener { - private let onErrorClosure: (String, ClientError) -> Void - - init(onErrorClosure: @escaping (String, ClientError) -> Void) { - self.onErrorClosure = onErrorClosure - } - - func onError(roomId: String, error: ClientError) { - onErrorClosure(roomId, error) - } -} - private struct ClientProxyServices { let syncService: SyncService let roomListService: RoomListService diff --git a/ElementX/Sources/Services/ElementCall/CXProviderProtocol.swift b/ElementX/Sources/Services/ElementCall/CXProviderProtocol.swift index ec72266c6..39a0eca30 100644 --- a/ElementX/Sources/Services/ElementCall/CXProviderProtocol.swift +++ b/ElementX/Sources/Services/ElementCall/CXProviderProtocol.swift @@ -10,7 +10,7 @@ import CallKit // sourcery: AutoMockable protocol CXProviderProtocol { func setDelegate(_ delegate: CXProviderDelegate?, queue: DispatchQueue?) - func reportNewIncomingCall(with uuid: UUID, update: CXCallUpdate, completion: @escaping (Error?) -> Void) + func reportNewIncomingCall(with uuid: UUID, update: CXCallUpdate, completion: @escaping @Sendable (Error?) -> Void) func reportCall(with uuid: UUID, endedAt: Date?, reason: CXCallEndedReason) } diff --git a/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift b/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift index e0752b09a..b03e61aeb 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallWidgetDriver.swift @@ -48,7 +48,7 @@ struct ElementCallWidgetMessage: Codable { } } -class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriverProtocol { +final class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriverProtocol { private let room: RoomProtocol private let deviceID: String diff --git a/ElementX/Sources/Services/Keychain/KeychainController.swift b/ElementX/Sources/Services/Keychain/KeychainController.swift index 8647c6eb9..13818c449 100644 --- a/ElementX/Sources/Services/Keychain/KeychainController.swift +++ b/ElementX/Sources/Services/Keychain/KeychainController.swift @@ -7,7 +7,7 @@ // import Foundation -import KeychainAccess +@preconcurrency import KeychainAccess import MatrixRustSDK enum KeychainControllerService: String { @@ -23,7 +23,7 @@ enum KeychainControllerService: String { } } -class KeychainController: KeychainControllerProtocol { +final class KeychainController: KeychainControllerProtocol { /// The keychain responsible for storing account restoration tokens (keyed by userID). private let restorationTokenKeychain: Keychain /// The keychain responsible for storing all other secrets in the app (keyed by `Key`s). diff --git a/ElementX/Sources/Services/Media/Provider/MediaFileHandleProxy.swift b/ElementX/Sources/Services/Media/Provider/MediaFileHandleProxy.swift index e90997523..30177ff95 100644 --- a/ElementX/Sources/Services/Media/Provider/MediaFileHandleProxy.swift +++ b/ElementX/Sources/Services/Media/Provider/MediaFileHandleProxy.swift @@ -58,7 +58,7 @@ extension MediaFileHandleProxy: Hashable { /// An unmanaged file handle that can be created direct from a URL. /// /// This type allows for mocking but doesn't provide the automatic clean-up mechanism provided by the SDK. -private class UnmanagedMediaFileHandle: MediaFileHandleProtocol { +private final class UnmanagedMediaFileHandle: MediaFileHandleProtocol { func persist(path: String) throws -> Bool { false } diff --git a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift index b4ebea8a1..e67e1fbdf 100644 --- a/ElementX/Sources/Services/Room/JoinedRoomProxy.swift +++ b/ElementX/Sources/Services/Room/JoinedRoomProxy.swift @@ -739,7 +739,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { // MARK: - Private private func subscribeToTypingNotifications() { - typingNotificationObservationToken = room.subscribeToTypingNotifications(listener: RoomTypingNotificationUpdateListener { [weak self] typingUserIDs in + typingNotificationObservationToken = room.subscribeToTypingNotifications(listener: SDKListener { [weak self] typingUserIDs in guard let self else { return } MXLog.info("Received typing notification update, typingUsers: \(typingUserIDs)") @@ -758,7 +758,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { private func subscribeToIdentityStatusChanges() async { do { - identityStatusChangesObservationToken = try await room.subscribeToIdentityStatusChanges(listener: RoomIdentityStatusChangeListener { [weak self] changes in + identityStatusChangesObservationToken = try await room.subscribeToIdentityStatusChanges(listener: SDKListener { [weak self] changes in guard let self else { return } MXLog.info("Received identity status changes: \(changes)") @@ -772,7 +772,7 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { private func subscribeToKnockRequests() async { do { - knockRequestsChangesObservationToken = try await room.subscribeToKnockRequests(listener: RoomKnockRequestsListener { [weak self] requests in + knockRequestsChangesObservationToken = try await room.subscribeToKnockRequests(listener: SDKListener { [weak self] requests in guard let self else { return } MXLog.info("Received requests to join update, requests id: \(requests.map(\.eventId))") @@ -801,39 +801,3 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol { return .exclude(eventTypes: stateEventFilters.map { FilterTimelineEventType.state(eventType: $0) }) }() } - -private final class RoomTypingNotificationUpdateListener: TypingNotificationsListener { - private let onUpdateClosure: ([String]) -> Void - - init(_ onUpdateClosure: @escaping ([String]) -> Void) { - self.onUpdateClosure = onUpdateClosure - } - - func call(typingUserIds: [String]) { - onUpdateClosure(typingUserIds) - } -} - -private final class RoomIdentityStatusChangeListener: IdentityStatusChangeListener { - private let onUpdateClosure: ([IdentityStatusChange]) -> Void - - init(_ onUpdateClosure: @escaping ([IdentityStatusChange]) -> Void) { - self.onUpdateClosure = onUpdateClosure - } - - func call(identityStatusChange: [IdentityStatusChange]) { - onUpdateClosure(identityStatusChange) - } -} - -private final class RoomKnockRequestsListener: KnockRequestsListener { - private let onUpdateClosure: ([KnockRequest]) -> Void - - init(_ onUpdateClosure: @escaping ([KnockRequest]) -> Void) { - self.onUpdateClosure = onUpdateClosure - } - - func call(joinRequests: [KnockRequest]) { - onUpdateClosure(joinRequests) - } -} diff --git a/ElementX/Sources/Services/SessionVerification/SessionVerificationControllerProxy.swift b/ElementX/Sources/Services/SessionVerification/SessionVerificationControllerProxy.swift index f4f5af88f..2406e357a 100644 --- a/ElementX/Sources/Services/SessionVerification/SessionVerificationControllerProxy.swift +++ b/ElementX/Sources/Services/SessionVerification/SessionVerificationControllerProxy.swift @@ -10,7 +10,7 @@ import Combine import Foundation import MatrixRustSDK -private class WeakSessionVerificationControllerProxy: SessionVerificationControllerDelegate { +private final class WeakSessionVerificationControllerProxy: SessionVerificationControllerDelegate { private weak var proxy: SessionVerificationControllerProxy? init(proxy: SessionVerificationControllerProxy) { diff --git a/NSE/Sources/NSEUserSession.swift b/NSE/Sources/NSEUserSession.swift index ca8cbc9a6..241e819b9 100644 --- a/NSE/Sources/NSEUserSession.swift +++ b/NSE/Sources/NSEUserSession.swift @@ -117,7 +117,7 @@ final class NSEUserSession { } } -private class ClientDelegateWrapper: ClientDelegate { +private final class ClientDelegateWrapper: ClientDelegate { // MARK: - ClientDelegate func didReceiveAuthError(isSoftLogout: Bool) {