Centralize SoureModel
This commit is contained in:
parent
0196d5c190
commit
5c53466dac
@ -105,7 +105,6 @@
|
||||
AF70699A287DD02400077CF6 /* ActionContactHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF706999287DD02400077CF6 /* ActionContactHandler.swift */; };
|
||||
AF70699E2880D01400077CF6 /* ActionShareHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF70699D2880D01400077CF6 /* ActionShareHandler.swift */; };
|
||||
AF7069A02880F0EB00077CF6 /* ActionOpenPageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF70699F2880F0EB00077CF6 /* ActionOpenPageHandler.swift */; };
|
||||
AF7069A22882293900077CF6 /* MVMCoreLoadHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF7069A12882293900077CF6 /* MVMCoreLoadHandler+Extension.swift */; };
|
||||
AF787413286DEF8B00670588 /* ActionBackHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF787412286DEF8B00670588 /* ActionBackHandler.swift */; };
|
||||
AF8D13392774EA1D008AF4A9 /* ActionOpenUrlHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */; };
|
||||
AFBB96341FBA34310008D868 /* MVMCoreErrorConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -268,7 +267,6 @@
|
||||
AF706999287DD02400077CF6 /* ActionContactHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionContactHandler.swift; sourceTree = "<group>"; };
|
||||
AF70699D2880D01400077CF6 /* ActionShareHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionShareHandler.swift; sourceTree = "<group>"; };
|
||||
AF70699F2880F0EB00077CF6 /* ActionOpenPageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPageHandler.swift; sourceTree = "<group>"; };
|
||||
AF7069A12882293900077CF6 /* MVMCoreLoadHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreLoadHandler+Extension.swift"; sourceTree = "<group>"; };
|
||||
AF787412286DEF8B00670588 /* ActionBackHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackHandler.swift; sourceTree = "<group>"; };
|
||||
AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlHandler.swift; sourceTree = "<group>"; };
|
||||
AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreErrorConstants.h; sourceTree = "<group>"; };
|
||||
@ -577,7 +575,6 @@
|
||||
AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */,
|
||||
AFBB96391FBA3A550008D868 /* MVMCoreLoadHandler.h */,
|
||||
AFBB964B1FBA3A560008D868 /* MVMCoreLoadHandler.m */,
|
||||
AF7069A12882293900077CF6 /* MVMCoreLoadHandler+Extension.swift */,
|
||||
AFBB964A1FBA3A560008D868 /* MVMCoreLoadRequestOperation.h */,
|
||||
AFBB96521FBA3A570008D868 /* MVMCoreLoadRequestOperation.m */,
|
||||
AFBB96471FBA3A560008D868 /* MVMCoreLoadObject.h */,
|
||||
@ -913,7 +910,6 @@
|
||||
AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */,
|
||||
D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */,
|
||||
AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */,
|
||||
AF7069A22882293900077CF6 /* MVMCoreLoadHandler+Extension.swift in Sources */,
|
||||
1DAD0FFE26AAB40000216E83 /* ActionRunJavaScriptModel.swift in Sources */,
|
||||
946EE1AB237B5C940036751F /* Decoder.swift in Sources */,
|
||||
AF70699A287DD02400077CF6 /* ActionContactHandler.swift in Sources */,
|
||||
|
||||
@ -17,8 +17,12 @@ open class ActionOpenPageHandler: MVMCoreJSONActionHandlerProtocol {
|
||||
if let closure = delegateObject?.actionDelegate?.handleOpenPage {
|
||||
// Legacy code will use the old handler function and break the task chain here.
|
||||
closure(model.requestParameters, JSON, additionalData)
|
||||
} else {
|
||||
try await performRequestAddingClientParameters(with: model.requestParameters, model: model, delegateObject: delegateObject, additionalData: additionalData)
|
||||
} else if let operation = try await performRequestAddingClientParameters(with: model.requestParameters, model: model, delegateObject: delegateObject, additionalData: additionalData) {
|
||||
await withCheckedContinuation { continuation in
|
||||
operation.completionBlock = {
|
||||
continuation.resume()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
try handle(error: error, model: model, delegateObject: delegateObject)
|
||||
@ -37,14 +41,14 @@ open class ActionOpenPageHandler: MVMCoreJSONActionHandlerProtocol {
|
||||
}
|
||||
|
||||
/// Adds client parameters and makes calls performRequest()
|
||||
open func performRequestAddingClientParameters(with requestParameters: MVMCoreRequestParameters, model: ActionOpenPageModel, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
|
||||
open func performRequestAddingClientParameters(with requestParameters: MVMCoreRequestParameters, model: ActionOpenPageModel, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws -> MVMCoreLoadRequestOperation? {
|
||||
// Adds any client parameters to the request parameters.
|
||||
if let parametersToFetch = model.clientParameters,
|
||||
let fetchedParameters = try await ClientParameterHandler().getClientParameters(with: parametersToFetch, requestParameters: requestParameters.parameters as? [String : Any] ?? [:], showLoadingOverlay: !requestParameters.backgroundRequest) {
|
||||
requestParameters.add(fetchedParameters)
|
||||
}
|
||||
try Task.checkCancellation()
|
||||
try await MVMCoreLoadHandler.sharedGlobal()?.performRequest(with: requestParameters, delegateObject: delegateObject, additionalData: additionalData)
|
||||
return MVMCoreLoadHandler.sharedGlobal()?.loadRequest(requestParameters, dataForPage: additionalData, delegateObject: delegateObject)
|
||||
}
|
||||
|
||||
/// Ensures background requests do not have showing errors.
|
||||
|
||||
@ -36,7 +36,12 @@ open class ActionPreviousSubmitHandler: MVMCoreJSONActionHandlerProtocol {
|
||||
let json = try json ?? MVMCoreActionHandler.convertActionToJSON(model)
|
||||
delegateObject?.actionDelegate?.handleOpenPage?(for: previousRequest, actionInformation: json, additionalData: additionalData)
|
||||
} else {
|
||||
try await MVMCoreLoadHandler.sharedGlobal()?.performRequest(with: previousRequest, delegateObject: delegateObject, additionalData: additionalData)
|
||||
guard let operation = MVMCoreLoadHandler.sharedGlobal()?.loadRequest(previousRequest, dataForPage: additionalData, delegateObject: delegateObject) else { return }
|
||||
await withCheckedContinuation { continuation in
|
||||
operation.completionBlock = {
|
||||
continuation.resume()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
//
|
||||
// MVMCoreLoadHandler+Extension.swift
|
||||
// MVMCore
|
||||
//
|
||||
// Created by Scott Pfeil on 7/15/22.
|
||||
// Copyright © 2022 myverizon. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension MVMCoreLoadHandler {
|
||||
/// Performs the request.
|
||||
func performRequest(with requestParameters: MVMCoreRequestParameters, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
|
||||
// Makes the request and waits for it. TODO: Any way to take errors into account?
|
||||
let operation = loadRequest(requestParameters, dataForPage: additionalData, delegateObject: delegateObject)
|
||||
await withCheckedContinuation { continuation in
|
||||
operation.completionBlock = {
|
||||
continuation.resume()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user