Skip to content

Commit 78f8b93

Browse files
author
Evan Greer
committed
refactors action runner
1 parent 1f01b0c commit 78f8b93

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

swift-sdk/Internal/ActionRunner.swift

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,27 @@ struct ActionRunner {
3030
urlOpener: UrlOpenerProtocol? = nil,
3131
allowedProtocols: [String] = []) -> Bool {
3232

33-
if case let .openUrl(url) = detectActionType(fromAction: action), shouldOpenUrl(url: url, from: context.source, withAllowedProtocols: allowedProtocols) {
34-
35-
let handled = callExternalHandlers(action: action,
36-
from: context.source,
37-
urlHandler: urlHandler,
38-
customActionHandler: customActionHandler)
39-
if handled {
40-
return true
41-
} else {
42-
if case let .openUrl(url) = detectActionType(fromAction: action),
43-
let urlOpener = urlOpener {
44-
urlOpener.open(url: url)
45-
return true
46-
} else {
47-
return false
48-
}
49-
}
50-
51-
} else {
33+
guard case let .openUrl(url) = detectActionType(fromAction: action),
34+
shouldOpenUrl(url: url, from: context.source, withAllowedProtocols: allowedProtocols) else {
5235
return false
5336
}
5437

38+
if case let handled = callExternalHandlers(action: action,
39+
from: context.source,
40+
urlHandler: urlHandler,
41+
customActionHandler: customActionHandler), handled {
42+
return true
43+
}
44+
45+
if case let .openUrl(url) = detectActionType(fromAction: action),
46+
let urlOpener = urlOpener {
47+
urlOpener.open(url: url)
48+
return true
49+
}
50+
51+
return false
52+
53+
5554
}
5655

5756
// MARK: - Private

0 commit comments

Comments
 (0)