mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
added tests
improvement improved improvement fixed
This commit is contained in:
@@ -195,6 +195,19 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
)
|
||||
}
|
||||
|
||||
func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool {
|
||||
guard let confirmationParameters = url.confirmationParameters else {
|
||||
return false
|
||||
}
|
||||
ServiceLocator.shared.userIndicatorController.alertInfo = .init(id: .init(),
|
||||
title: L10n.dialogConfirmLinkTitle,
|
||||
message: L10n.dialogConfirmLinkMessage(confirmationParameters.displayString,
|
||||
confirmationParameters.internalURL.absoluteString),
|
||||
primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil),
|
||||
secondaryButton: .init(title: L10n.actionContinue) { openURLAction(confirmationParameters.internalURL) })
|
||||
return true
|
||||
}
|
||||
|
||||
func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool {
|
||||
// Parse into an AppRoute to redirect these in a type safe way.
|
||||
|
||||
|
||||
@@ -13,5 +13,7 @@ protocol AppCoordinatorProtocol: CoordinatorProtocol {
|
||||
|
||||
@discardableResult func handleDeepLink(_ url: URL, isExternalURL: Bool) -> Bool
|
||||
|
||||
func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool
|
||||
|
||||
func handleUserActivity(_ userActivity: NSUserActivity)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import SwiftUI
|
||||
struct Application: App {
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
||||
@Environment(\.openURL) private var openURL
|
||||
@State private var alert: AlertInfo<ApplicationAlertType>?
|
||||
|
||||
private var appCoordinator: AppCoordinatorProtocol!
|
||||
|
||||
@@ -36,20 +35,16 @@ struct Application: App {
|
||||
return .handled
|
||||
}
|
||||
|
||||
if let confirmationParameters = url.confirmationParameters {
|
||||
alert = .init(id: .confirmURL,
|
||||
title: "Test",
|
||||
message: "Test",
|
||||
primaryButton: .init(title: "Confirm") { openURL(confirmationParameters.internalURL) },
|
||||
secondaryButton: .init(title: L10n.actionCancel, action: nil))
|
||||
|
||||
if appCoordinator.handlePotentialPhishingAttempt(url: url, openURLAction: { url in
|
||||
openURL(url, isExternalURL: false)
|
||||
}) {
|
||||
return .handled
|
||||
}
|
||||
|
||||
return .systemAction
|
||||
})
|
||||
.onOpenURL { url in
|
||||
openURL(url)
|
||||
openURL(url, isExternalURL: true)
|
||||
}
|
||||
.onContinueUserActivity("INStartVideoCallIntent") { userActivity in
|
||||
// `INStartVideoCallIntent` is to be replaced with `INStartCallIntent`
|
||||
@@ -59,14 +54,13 @@ struct Application: App {
|
||||
.task {
|
||||
appCoordinator.start()
|
||||
}
|
||||
.alert(item: $alert)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func openURL(_ url: URL) {
|
||||
if !appCoordinator.handleDeepLink(url, isExternalURL: true) {
|
||||
private func openURL(_ url: URL, isExternalURL: Bool) {
|
||||
if !appCoordinator.handleDeepLink(url, isExternalURL: isExternalURL) {
|
||||
openURLInSystemBrowser(url)
|
||||
}
|
||||
}
|
||||
@@ -97,7 +91,3 @@ struct Application: App {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
enum ApplicationAlertType {
|
||||
case confirmURL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user