philips-software/cogito

View on GitHub
workspaces/cogito-ios-app/Cogito/URL handler/URLActions.swift

Summary

Maintainability
A
0 mins
Test Coverage
A
93%
import Foundation
import ReSwiftThunk

struct URLActions {
    static func HandleIncomingURL(url: URL) -> Thunk<AppState> { // swiftlint:disable:this identifier_name
        return Thunk { dispatch, getState in
            guard let identity = getState()?.diamond.selectedFacet() else {
                return
            }

            switch url.pathComponents.suffix(2) {
            case ["telepath", "connect"]:
                dispatch(TelepathActions.Connect(url: url, for: identity))
            case ["attestations", "receive"]:
                dispatch(AttestationActions.ReceiveAttestation(url: url))
            default:
                break
            }
        }
    }
}