From 36ec79f353dd95fca81cc7ed75d4c5a1c76aa124 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 29 Jul 2022 16:20:21 -0400 Subject: [PATCH] Descriptor changes --- MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift | 2 +- MVMCore/MVMCore/ActionHandling/ActionOpenUrlHandler.swift | 3 ++- MVMCore/MVMCore/ActionHandling/ActionShareHandler.swift | 3 ++- MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift | 5 ++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift index 30f2594..aa80a9a 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionBackHandler.swift @@ -21,7 +21,7 @@ open class ActionBackHandler: MVMCoreJSONActionHandlerProtocol { } open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { - await withCheckedContinuation { (continuation: CheckedContinuation) in + await withCheckedContinuation { continuation in Task(priority: .userInitiated) { await MVMCoreNavigationHandler.shared()?.removeCurrentViewController(true, completionHandler: { continuation.resume() diff --git a/MVMCore/MVMCore/ActionHandling/ActionOpenUrlHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionOpenUrlHandler.swift index 5f8dbf1..b731613 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionOpenUrlHandler.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionOpenUrlHandler.swift @@ -49,7 +49,8 @@ open class ActionOpenUrlHandler: MVMCoreJSONActionHandlerProtocol { } /// Opens the url using UIApplication open(url:). Throws URLError.failedToOpen if it fails. - @MainActor public static func open(url: URL) async throws { + @MainActor + public static func open(url: URL) async throws { try await withCheckedThrowingContinuation { continuation in UIApplication.shared.open(url, options: [:]) { successful in if successful { diff --git a/MVMCore/MVMCore/ActionHandling/ActionShareHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionShareHandler.swift index 77dbebf..64fff19 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionShareHandler.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionShareHandler.swift @@ -24,7 +24,8 @@ open class ActionShareHandler: MVMCoreActionHandlerProtocol { try await shareWith(activityItems: shareData, model: model) } - @MainActor open func shareWith(activityItems: [Any], model: ActionShareModel, delegateObject: DelegateObject? = nil) async throws { + @MainActor + open func shareWith(activityItems: [Any], model: ActionShareModel, delegateObject: DelegateObject? = nil) async throws { try await withCheckedThrowingContinuation { continuation in let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: nil) controller.popoverPresentationController?.sourceView = MVMCoreNavigationHandler.shared()?.viewControllerToPresentOn?.view diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift index 9ecd2fd..a5490de 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler.swift @@ -139,6 +139,7 @@ extension MVMCoreActionHandlerProtocol { } /// Performs the action as a task and returns immediately. + @discardableResult open func asyncHandleAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> Task { let task = Task(priority: .userInitiated) { try Task.checkCancellation() @@ -173,9 +174,7 @@ extension MVMCoreActionHandlerProtocol { /// Subclass to log the action was fired. open func logAction(with model: ActionModelProtocol, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { // Calls legacy log action function. - Task { - delegateObject?.actionDelegate?.logAction?(withActionInformation: model.toJSON(), additionalData: additionalData) - } + delegateObject?.actionDelegate?.logAction?(withActionInformation: model.toJSON(), additionalData: additionalData) } /// Logs the error.