Skip to content

Commit

Permalink
Don't worry about the generic call links.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jul 19, 2024
1 parent 30234d4 commit d00f05e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ElementX/Sources/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
if let userSessionFlowCoordinator {
userSessionFlowCoordinator.handleAppRoute(route, animated: true)
} else {
navigationRootCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url, appHooks: appHooks)))
navigationRootCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)))
}
case .userProfile(let userID):
if isExternalURL {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
await presentCallScreen(roomID: roomID)
}
case .genericCallLink(let url):
navigationSplitCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url, appHooks: appHooks)), animated: animated)
navigationSplitCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)), animated: animated)
case .settings, .chatBackupSettings:
settingsFlowCoordinator.handleAppRoute(appRoute, animated: animated)
case .oidcCallback:
Expand Down
14 changes: 3 additions & 11 deletions ElementX/Sources/Screens/Other/GenericCallLinkCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import WebKit

struct GenericCallLinkCoordinatorParameters {
let url: URL
let appHooks: AppHooks
}

private enum GenericCallLinkQueryParameters {
Expand All @@ -35,7 +34,7 @@ class GenericCallLinkCoordinator: CoordinatorProtocol {
}

func toPresentable() -> AnyView {
AnyView(WebView(url: parameters.url, certificateValidator: parameters.appHooks.certificateValidatorHook)
AnyView(WebView(url: parameters.url)
// This URL is stable, forces view reloads if this representable is ever reused for another url
.id(parameters.url)
.ignoresSafeArea(edges: .bottom)
Expand All @@ -45,14 +44,13 @@ class GenericCallLinkCoordinator: CoordinatorProtocol {

private struct WebView: UIViewRepresentable {
let url: URL
let certificateValidator: CertificateValidatorHookProtocol

func makeUIView(context: Context) -> WKWebView {
context.coordinator.webView
}

func makeCoordinator() -> Coordinator {
Coordinator(url: url, certificateValidator: certificateValidator)
Coordinator(url: url)
}

func updateUIView(_ webView: WKWebView, context: Context) {
Expand All @@ -62,11 +60,9 @@ private struct WebView: UIViewRepresentable {
@MainActor
class Coordinator: NSObject, WKUIDelegate, WKNavigationDelegate {
let url: URL
let certificateValidator: CertificateValidatorHookProtocol
private(set) var webView: WKWebView!

init(url: URL, certificateValidator: CertificateValidatorHookProtocol) {
self.certificateValidator = certificateValidator
init(url: URL) {
if var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: true) {
var fragmentQueryItems = urlComponents.fragmentQueryItems ?? []

Expand Down Expand Up @@ -113,10 +109,6 @@ private struct WebView: UIViewRepresentable {

// MARK: - WKNavigationDelegate

func webView(_ webView: WKWebView, respondTo challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?) {
await certificateValidator.respondTo(challenge)
}

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy {
// Allow any content from the main URL.
if navigationAction.request.url?.host == url.host {
Expand Down

0 comments on commit d00f05e

Please sign in to comment.