From eea70d830680dbeb84620763ce4424b0ae288ae3 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Tue, 3 Nov 2020 12:31:06 -0500 Subject: [PATCH 1/4] Remove no page error --- .../MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 7bce64d..f04df88 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -167,15 +167,8 @@ // Can continue loading with the page. [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:error]; - } else if (loadObject.operation.alertToShow || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { - - // Alert to show and finish, or nothing to show and asked to show and finish. - [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; } else { - - // Error, no message and no page but we wanted to show something. - MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; - [MVMCoreLoadRequestOperation loadAbortedWithError:error loadObject:loadObject]; + [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; } }]; }]; From e3b089c294addb28c1fdb703d21d8a64eeda39b5 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 4 Nov 2020 09:56:00 -0500 Subject: [PATCH 2/4] Change to check no content errors --- .../LoadHandling/MVMCoreLoadRequestOperation.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 3231d11..3b244a7 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -167,8 +167,15 @@ // Can continue loading with the page. [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:error]; - } else { + } else if ([MVMCoreLoadRequestOperation hasSomethingToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { + + // Something to show, or nothing was expected to show, can finish. [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; + } else { + + // Error, foreground request with no page, alert, action, or anything else to show. Abort with error. + MVMCoreErrorObject *error = [[MVMCoreErrorObject alloc] initWithTitle:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle] message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] code:ErrorCodeNoPageType domain:ErrorDomainNative location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]]; + [MVMCoreLoadRequestOperation loadAbortedWithError:error loadObject:loadObject]; } }]; }]; @@ -725,6 +732,10 @@ }]; } ++ (BOOL)hasSomethingToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { + return loadObject.operation.alertToShow || [loadObject.responseJSON objectForKey:@"PostAction"] || [loadObject.responseJSON objectForKey:@"TopNotification"]; +} + + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable { if ([loadObject.operation checkAndHandleForCancellation]) { From 03152f9f8b7b8e8690072593e34c0bf40b02736b Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 4 Nov 2020 09:57:42 -0500 Subject: [PATCH 3/4] Changed method name --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h | 3 +++ MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h index 17b6d1e..22b8cb9 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h @@ -88,6 +88,9 @@ // Displays the view controller to the screen. + (void)displayViewController:(nonnull UIViewController *)viewController loadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; +/// Checks to see if the operation has content to show. ++ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; + // Handles the error based on the error object passed in. May log and/or display the error. + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 3b244a7..e1b4e78 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -167,7 +167,7 @@ // Can continue loading with the page. [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:error]; - } else if ([MVMCoreLoadRequestOperation hasSomethingToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { + } else if ([MVMCoreLoadRequestOperation hasContentToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { // Something to show, or nothing was expected to show, can finish. [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; @@ -732,7 +732,7 @@ }]; } -+ (BOOL)hasSomethingToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { ++ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { return loadObject.operation.alertToShow || [loadObject.responseJSON objectForKey:@"PostAction"] || [loadObject.responseJSON objectForKey:@"TopNotification"]; } From e3422124f59a49f35f2eb32c7a53f1a75d403d85 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 4 Nov 2020 11:03:32 -0500 Subject: [PATCH 4/4] Review changes --- MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h | 1 + MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m | 1 + .../MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h | 6 +++--- .../MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 8 ++------ MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h | 3 +++ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h index 90f1854..f3d84ac 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.h @@ -24,6 +24,7 @@ extern NSString * const KeyPageMap; extern NSString * const KeySystemParameters; extern NSString * const KeyButtonMap; extern NSString * const KeyOpenSupport; +extern NSString * const KeyPostAction; extern NSString * const KeyLinks; extern NSString * const KeyTitle; diff --git a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m index ac69a76..71cccac 100644 --- a/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m +++ b/MVMCore/MVMCore/Constants/MVMCoreJSONConstants.m @@ -26,6 +26,7 @@ NSString * const KeyPageMap = @"PageMap"; NSString * const KeySystemParameters = @"SystemParams"; NSString * const KeyButtonMap = @"ButtonMap"; NSString * const KeyOpenSupport = @"openSupport"; +NSString * const KeyPostAction = @"PostAction"; NSString * const KeyLinks = @"Links"; NSString * const KeyTitle = @"title"; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h index 22b8cb9..158b991 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h @@ -26,6 +26,9 @@ @property (nonatomic) BOOL backgroundLoad; @property (nonatomic, getter=areDependenciesAdded) BOOL dependenciesAdded; +/// Legacy flag for if this operation will have an alert to show when finished. +@property (nonatomic, readonly) BOOL alertToShow; + // Initializes the operation with the request parameters object, data for page, and mvm view controller to handle the loading with. - (nullable instancetype)initWithRequestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegateObject:(nullable DelegateObject *)delegateObject backgroundLoad:(BOOL)backgroundLoad; @@ -88,9 +91,6 @@ // Displays the view controller to the screen. + (void)displayViewController:(nonnull UIViewController *)viewController loadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; -/// Checks to see if the operation has content to show. -+ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; - // Handles the error based on the error object passed in. May log and/or display the error. + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index e1b4e78..54e6f20 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -34,7 +34,7 @@ @property (weak, nonatomic) NSURLSessionTask *sessionTask; // For temporarily storing any alert to show until we determine it's delegate. -@property (nonatomic) BOOL alertToShow; +@property (nonatomic, readwrite) BOOL alertToShow; @property (strong, nonatomic, nullable) MVMCoreErrorObject *errorForAlertToShow; @end @@ -167,7 +167,7 @@ // Can continue loading with the page. [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:error]; - } else if ([MVMCoreLoadRequestOperation hasContentToShow:loadObject error:error] || loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad) { + } else if (loadObject.operation.backgroundLoad || loadObject.requestParameters.noViewControllerToLoad || ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(hasContentToShow:error:)] && [[MVMCoreObject sharedInstance].globalLoadDelegate hasContentToShow:loadObject error:error])) { // Something to show, or nothing was expected to show, can finish. [MVMCoreLoadRequestOperation loadFinished:loadObject loadedViewController:nil errorObject:error]; @@ -732,10 +732,6 @@ }]; } -+ (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error { - return loadObject.operation.alertToShow || [loadObject.responseJSON objectForKey:@"PostAction"] || [loadObject.responseJSON objectForKey:@"TopNotification"]; -} - + (void)handleError:(nonnull MVMCoreErrorObject *)error loadObject:(nonnull MVMCoreLoadObject *)loadObject showAlertForErrorIfApplicable:(BOOL)showAlertForErrorIfApplicable { if ([loadObject.operation checkAndHandleForCancellation]) { diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h index 027d6b7..65ea153 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h @@ -38,4 +38,7 @@ // Shows the appropriate alert style for the given response info and/or error. - (void)createAndShowAlertForLoadObject:(nullable MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error delegateObject:(nullable DelegateObject *)delegateObject; +/// Checks to see if the operation has content to show. +- (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; + @end