Fix some warnings. (#3416)

This commit is contained in:
Doug
2024-10-16 08:54:34 +01:00
committed by GitHub
parent 236d142583
commit 718774dc36
10 changed files with 48 additions and 43 deletions
@@ -137,33 +137,6 @@ class AuthenticationFlowCoordinator: FlowCoordinatorProtocol {
bugReportFlowCoordinator?.start()
}
// TODO: Move this method after showServerConfirmationScreen
private func showServerSelectionScreen(authenticationFlow: AuthenticationFlow) {
let navigationCoordinator = NavigationStackCoordinator()
let parameters = ServerSelectionScreenCoordinatorParameters(authenticationService: authenticationService,
authenticationFlow: authenticationFlow,
slidingSyncLearnMoreURL: appSettings.slidingSyncLearnMoreURL,
userIndicatorController: userIndicatorController)
let coordinator = ServerSelectionScreenCoordinator(parameters: parameters)
coordinator.actions
.sink { [weak self] action in
guard let self else { return }
switch action {
case .updated:
navigationStackCoordinator.setSheetCoordinator(nil)
case .dismiss:
navigationStackCoordinator.setSheetCoordinator(nil)
}
}
.store(in: &cancellables)
navigationCoordinator.setRootCoordinator(coordinator)
navigationStackCoordinator.setSheetCoordinator(navigationCoordinator)
}
private func showServerConfirmationScreen(authenticationFlow: AuthenticationFlow) {
// Reset the service back to the default homeserver before continuing. This ensures
// we check that registration is supported if it was previously configured for login.
@@ -196,6 +169,32 @@ class AuthenticationFlowCoordinator: FlowCoordinatorProtocol {
navigationStackCoordinator.push(coordinator)
}
private func showServerSelectionScreen(authenticationFlow: AuthenticationFlow) {
let navigationCoordinator = NavigationStackCoordinator()
let parameters = ServerSelectionScreenCoordinatorParameters(authenticationService: authenticationService,
authenticationFlow: authenticationFlow,
slidingSyncLearnMoreURL: appSettings.slidingSyncLearnMoreURL,
userIndicatorController: userIndicatorController)
let coordinator = ServerSelectionScreenCoordinator(parameters: parameters)
coordinator.actions
.sink { [weak self] action in
guard let self else { return }
switch action {
case .updated:
navigationStackCoordinator.setSheetCoordinator(nil)
case .dismiss:
navigationStackCoordinator.setSheetCoordinator(nil)
}
}
.store(in: &cancellables)
navigationCoordinator.setRootCoordinator(coordinator)
navigationStackCoordinator.setSheetCoordinator(navigationCoordinator)
}
private func showWebRegistration() {
let parameters = WebRegistrationScreenCoordinatorParameters(authenticationService: authenticationService,
userIndicatorController: userIndicatorController)
@@ -13,7 +13,7 @@ extension Dictionary {
options: [.fragmentsAllowed, .sortedKeys]) else {
return nil
}
return String(decoding: data, as: UTF8.self)
return String(data: data, encoding: .utf8)
}
/// Returns a dictionary containing the original values keyed by the results of mapping the given closure over its keys.
@@ -213,14 +213,20 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
}
private func postMessageToWidget(_ message: ElementCallWidgetMessage) async {
let data: Data
do {
let data = try JSONEncoder().encode(message)
let json = String(decoding: data, as: UTF8.self)
await postJSONToWidget(json)
data = try JSONEncoder().encode(message)
} catch {
MXLog.error("Failed encoding widget message with error: \(error)")
return
}
guard let json = String(data: data, encoding: .utf8) else {
MXLog.error("Invalid data for widget message")
return
}
await postJSONToWidget(json)
}
private func postJSONToWidget(_ json: String) async {
@@ -93,7 +93,7 @@ class CreateRoomViewModel: CreateRoomViewModelType, CreateRoomViewModelProtocol
old.roomName == new.roomName && old.roomTopic == new.roomTopic && old.isRoomPrivate == new.isRoomPrivate
}
.sink { [weak self] bindings in
guard let self = self else { return }
guard let self else { return }
updateParameters(bindings: bindings)
actionsSubject.send(.updateDetails(createRoomParameters))
}
@@ -117,14 +117,14 @@ class BugReportService: NSObject, BugReportServiceProtocol {
let (data, response) = try await session.dataWithRetry(for: request, delegate: self)
guard let httpResponse = response as? HTTPURLResponse else {
let errorDescription = String(decoding: data, as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines)
let errorDescription = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "Unknown error"
MXLog.error("Failed to submit bug report: \(errorDescription)")
MXLog.error("Response: \(response)")
return .failure(.serverError(response, errorDescription))
}
guard httpResponse.statusCode == 200 else {
let errorDescription = String(decoding: data, as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines)
let errorDescription = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "Unknown error"
MXLog.error("Failed to submit bug report: \(errorDescription) (\(httpResponse.statusCode))")
MXLog.error("Response: \(httpResponse)")
return .failure(.httpError(httpResponse, errorDescription))
@@ -365,6 +365,7 @@ class ClientProxy: ClientProxyProtocol {
}
}
// swiftlint:disable:next function_parameter_count
func createRoom(name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?) async -> Result<String, ClientProxyError> {
do {
// TODO: Revisit once the SDK supports the knocking API
@@ -138,6 +138,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
func createDirectRoom(with userID: String, expectedRoomName: String?) async -> Result<String, ClientProxyError>
// swiftlint:disable:next function_parameter_count
func createRoom(name: String, topic: String?, isRoomPrivate: Bool, isKnockingOnly: Bool, userIDs: [String], avatarURL: URL?) async -> Result<String, ClientProxyError>
func joinRoom(_ roomID: String, via: [String]) async -> Result<Void, ClientProxyError>
@@ -299,8 +299,6 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
switch action {
case .roomInfoUpdate:
return (roomProxy.hasOngoingCall, roomProxy.activeRoomCallParticipants)
default:
return nil
}
}
.removeDuplicates { $0 == $1 }
@@ -208,7 +208,7 @@ struct TimelineItemDebugInfo: Identifiable, CustomStringConvertible {
return nil
}
return String(decoding: jsonData, as: UTF8.self)
return String(data: jsonData, encoding: .utf8)
}
}
@@ -137,10 +137,11 @@ enum UITestsSignalling {
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
guard let data = try? encoder.encode(self) else {
guard let data = try? encoder.encode(self),
let rawMessage = String(data: data, encoding: .utf8) else {
return "unknown"
}
return String(decoding: data, as: UTF8.self)
return rawMessage
}
init?(rawValue: String) {
@@ -165,9 +166,8 @@ enum UITestsSignalling {
/// Processes string data from the file and publishes its signal.
private func processFileData(_ data: Data) {
let rawMessage = String(decoding: data, as: UTF8.self)
guard let message = Message(rawValue: rawMessage),
guard let rawMessage = String(data: data, encoding: .utf8),
let message = Message(rawValue: rawMessage),
message.mode != mode // Filter out messages sent by this client.
else { return }