From 59ff7d2fad90435e14fac5e19597a38d9c62308c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 22 Oct 2021 15:05:24 -0500 Subject: [PATCH] fix for legacy Signed-off-by: Matt Bruce --- .../MVMCoreActionHandler+Extension.swift | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift index 48484d9..23bb047 100644 --- a/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift +++ b/MVMCore/MVMCore/ActionHandling/MVMCoreActionHandler+Extension.swift @@ -44,37 +44,32 @@ public extension MVMCoreActionHandler { @objc func hasActionHandler(actionType: String?, actionInformation: [String: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> Bool { //ensure there is a Serialized version of the Action - guard let actionType = actionType, let actionInformation = actionInformation else { return false } + guard let actionType = actionType, + let actionInformation = actionInformation, + let actionModelType = ModelRegistry.getType(for: actionType, with: ActionModelProtocol.self) + else { return false } do { - //get the actionModelType - guard let actionModelType = ModelRegistry.getType(for: actionType, with: ActionModelProtocol.self) else { - throw ModelRegistry.Error.decoderErrorModelNotMapped() - } - //deserialize the actionModel for the actionType found guard let actionModel = try actionModelType.decode(jsonDict: actionInformation) as? ActionModelProtocol else { throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol") } - + //get the action Handler for the actionModel created let actionHandler = try ModelRegistry.getActionHandler(actionModel) //call the handleAction of the handler actionHandler.handleAction(actionModel, additionalData: additionalData, delegateObject: delegateObject) - //complete - return true - } catch { //log the error if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "") { MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: additionalData) } - - //incomplete - return false } + + //complete + return true } /// Start action on current thread.