Minor cleanup

This commit is contained in:
Scott Pfeil 2022-07-22 10:20:46 -04:00
parent f123be046c
commit 71b2146862

View File

@ -49,33 +49,26 @@ open class ActionOpenPageHandler: MVMCoreActionHandlerProtocol {
} }
public extension ClientParameterHandler { public extension ClientParameterHandler {
/// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters. /// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters.
func getClientParameters(with model: ClientParameterModel, requestParameters: [String: Any], showLoadingOverlay: Bool) async throws -> [String: Any]? { func getClientParameters(with model: ClientParameterModel, requestParameters: [String: Any], showLoadingOverlay: Bool) async throws -> [String: Any]? {
if showLoadingOverlay { if showLoadingOverlay {
MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading() MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading()
} }
defer {
do {
let parameters: [String: Any]? = try await withCheckedThrowingContinuation({ continuation in
do {
try getParameters(with: model, requestParameters: requestParameters) { parameters in
MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true)
continuation.resume(returning: parameters)
}
} catch {
continuation.resume(throwing: error)
}
})
if showLoadingOverlay { if showLoadingOverlay {
MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true) MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true)
} }
return parameters
} catch {
if showLoadingOverlay {
MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true)
}
throw error
} }
return try await withCheckedThrowingContinuation({ continuation in
do {
try getParameters(with: model, requestParameters: requestParameters) { parameters in
MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true)
continuation.resume(returning: parameters)
}
} catch {
continuation.resume(throwing: error)
}
})
} }
} }