mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 20:39:24 +00:00
Add SwiftFormat to the project. (#129)
* Run swiftformat for whitespace. * Run swiftformat with some rules.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -61,20 +61,20 @@ class SessionVerificationStateMachine {
|
||||
// swiftlint:disable cyclomatic_complexity
|
||||
init() {
|
||||
stateMachine = StateMachine(state: .initial) { machine in
|
||||
machine.addRoutes(event: .requestVerification, transitions: [ .initial => .requestingVerification ])
|
||||
machine.addRoutes(event: .didFail, transitions: [ .requestingVerification => .initial ])
|
||||
machine.addRoutes(event: .requestVerification, transitions: [.initial => .requestingVerification])
|
||||
machine.addRoutes(event: .didFail, transitions: [.requestingVerification => .initial])
|
||||
|
||||
machine.addRoutes(event: .cancel, transitions: [ .requestingVerification => .cancelling ])
|
||||
machine.addRoutes(event: .didCancel, transitions: [ .requestingVerification => .cancelled ])
|
||||
machine.addRoutes(event: .cancel, transitions: [.requestingVerification => .cancelling])
|
||||
machine.addRoutes(event: .didCancel, transitions: [.requestingVerification => .cancelled])
|
||||
|
||||
// Cancellation request from the other party should either take us from `.cancelling`
|
||||
// to `.cancelled` or keep us in `.cancelled` if already there. There is more `.didCancel`
|
||||
// handling in `addRouteMapping` for states containing associated values
|
||||
machine.addRoutes(event: .didCancel, transitions: [ .cancelling => .cancelled ])
|
||||
machine.addRoutes(event: .didCancel, transitions: [ .cancelled => .cancelled ])
|
||||
machine.addRoutes(event: .didFail, transitions: [ .cancelled => .cancelled ])
|
||||
machine.addRoutes(event: .didCancel, transitions: [.cancelling => .cancelled])
|
||||
machine.addRoutes(event: .didCancel, transitions: [.cancelled => .cancelled])
|
||||
machine.addRoutes(event: .didFail, transitions: [.cancelled => .cancelled])
|
||||
|
||||
machine.addRoutes(event: .restart, transitions: [ .cancelled => .initial ])
|
||||
machine.addRoutes(event: .restart, transitions: [.cancelled => .initial])
|
||||
|
||||
// Transitions with associated values need to be handled through `addRouteMapping`
|
||||
machine.addRouteMapping { event, fromState, _ in
|
||||
@@ -115,6 +115,7 @@ class SessionVerificationStateMachine {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// swiftlint:enable cyclomatic_complexity
|
||||
|
||||
/// Attempt to move the state machine to another state through an event
|
||||
|
||||
@@ -75,8 +75,8 @@ class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVer
|
||||
callback?(.finished)
|
||||
case .cancel:
|
||||
guard stateMachine.state == .initial ||
|
||||
stateMachine.state == .verified ||
|
||||
stateMachine.state == .cancelled else {
|
||||
stateMachine.state == .verified ||
|
||||
stateMachine.state == .cancelled else {
|
||||
stateMachine.processEvent(.cancel)
|
||||
return
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVer
|
||||
private func requestVerification() {
|
||||
Task {
|
||||
switch await sessionVerificationControllerProxy.requestVerification() {
|
||||
case.success:
|
||||
case .success:
|
||||
// Need to wait for the callback from the remote
|
||||
break
|
||||
case .failure:
|
||||
@@ -131,7 +131,7 @@ class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVer
|
||||
private func cancelVerification() {
|
||||
Task {
|
||||
switch await sessionVerificationControllerProxy.cancelVerification() {
|
||||
case.success:
|
||||
case .success:
|
||||
stateMachine.processEvent(.didCancel)
|
||||
case .failure:
|
||||
stateMachine.processEvent(.didFail)
|
||||
@@ -142,7 +142,7 @@ class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVer
|
||||
private func acceptChallenge() {
|
||||
Task {
|
||||
switch await sessionVerificationControllerProxy.approveVerification() {
|
||||
case.success:
|
||||
case .success:
|
||||
// Need to wait for the callback from the remote
|
||||
break
|
||||
case .failure:
|
||||
@@ -154,7 +154,7 @@ class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVer
|
||||
private func declineChallenge() {
|
||||
Task {
|
||||
switch await sessionVerificationControllerProxy.declineVerification() {
|
||||
case.success:
|
||||
case .success:
|
||||
stateMachine.processEvent(.didCancel)
|
||||
case .failure:
|
||||
stateMachine.processEvent(.didFail)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import MatrixRustSDK
|
||||
import SwiftUI
|
||||
|
||||
struct SessionVerificationScreen: View {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user