fix for legacy
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
6c8bb9ce4b
commit
59ff7d2fad
@ -44,37 +44,32 @@ public extension MVMCoreActionHandler {
|
|||||||
|
|
||||||
@objc func hasActionHandler(actionType: String?, actionInformation: [String: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> Bool {
|
@objc func hasActionHandler(actionType: String?, actionInformation: [String: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> Bool {
|
||||||
//ensure there is a Serialized version of the Action
|
//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 {
|
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
|
//deserialize the actionModel for the actionType found
|
||||||
guard let actionModel = try actionModelType.decode(jsonDict: actionInformation) as? ActionModelProtocol else {
|
guard let actionModel = try actionModelType.decode(jsonDict: actionInformation) as? ActionModelProtocol else {
|
||||||
throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol")
|
throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol")
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the action Handler for the actionModel created
|
//get the action Handler for the actionModel created
|
||||||
let actionHandler = try ModelRegistry.getActionHandler(actionModel)
|
let actionHandler = try ModelRegistry.getActionHandler(actionModel)
|
||||||
|
|
||||||
//call the handleAction of the handler
|
//call the handleAction of the handler
|
||||||
actionHandler.handleAction(actionModel, additionalData: additionalData, delegateObject: delegateObject)
|
actionHandler.handleAction(actionModel, additionalData: additionalData, delegateObject: delegateObject)
|
||||||
|
|
||||||
//complete
|
|
||||||
return true
|
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
//log the error
|
//log the error
|
||||||
if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "") {
|
if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "") {
|
||||||
MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: additionalData)
|
MVMCoreActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: additionalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
//incomplete
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//complete
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start action on current thread.
|
/// Start action on current thread.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user