From 147a237ba96860503f1bb810c6e41f55085ddad5 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 30 Oct 2020 14:10:14 -0400 Subject: [PATCH 1/9] enhance controller registration to allow for configuration --- ...VMCoreViewControllerProgrammaticMappingObject.h | 4 ++++ ...VMCoreViewControllerProgrammaticMappingObject.m | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h index 02487e0..fc03b06 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h @@ -13,7 +13,11 @@ // View Controller Class, for loading by class. @property (nonnull, strong, nonatomic) Class viewControllerClass; +@property (nullable, copy, nonatomic) void (^configureHandler)(UIViewController * _Nonnull); + // Initializes with the given class. - (nullable id)initWithClass:(nonnull Class)viewControllerClass; +- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock; + @end diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m index 8547285..a47a583 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.m @@ -19,8 +19,20 @@ return self; } +- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^)(UIViewController * _Nonnull))configureBlock { + self = [self initWithClass:viewControllerClass]; + if (self) { + self.configureHandler = configureBlock; + } + return self; +} + - (nullable UIViewController *)createViewController { - return [[self.viewControllerClass alloc] init]; + UIViewController *newController = [[self.viewControllerClass alloc] init]; + if (self.configureHandler) { + self.configureHandler(newController); + } + return newController; } @end From 5466c75c5cd794d7a9f56447eda69823c3fbc875 Mon Sep 17 00:00:00 2001 From: Nishanth T Date: Mon, 2 Nov 2020 12:04:53 +0530 Subject: [PATCH 2/9] Update MVMCoreLoadRequestOperation.m added function to display alert from "Action" object in response level --- .../LoadHandling/MVMCoreLoadRequestOperation.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 7bce64d..2bf4fde 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -796,7 +796,7 @@ } //make post load calls function - [MVMCoreLoadRequestOperation loadPostCallActions:loadObject]; + [MVMCoreLoadRequestOperation loadCallActions:loadObject]; [loadObject.operation markAsFinished]; } @@ -819,6 +819,20 @@ } } ++ (void)loadCallActions:(nonnull MVMCoreLoadObject *)loadObject { + NSDictionary *actionDict = [loadObject.responseJSON dict:@"Action"]; + if (actionDict) { + //TODO needs to create operation queue based on concurrent flag + //BOOL isConcurrent = [postCallsDict boolForKey:@"concurrent"]; + //Needs further enhancements based on the flags. + BOOL shouldTriggerFromCache = [actionDict boolForKey:@"shouldTriggerFromCache"]; + //Check if page is not from cache + if (!loadObject.pageDataFromCache || shouldTriggerFromCache) { + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionDict additionalData:nil delegateObject:nil]; + } + } +} + + (void)removeCaches:(nullable NSDictionary *)cacheDictionary { if (cacheDictionary) { From f1871ac7d12bc73fc92084dd536823055b7701fa Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Mon, 2 Nov 2020 11:07:11 -0500 Subject: [PATCH 3/9] adding back removed import --- MVMCore/MVMCore/MVMCore.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index fa613c5..ca0b8a0 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -62,6 +62,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import +#import // Action Handling #import From e6a402a5bcdac7ec3d3134266d7a4889723cfbbf Mon Sep 17 00:00:00 2001 From: Nishanth T Date: Tue, 3 Nov 2020 15:22:21 +0530 Subject: [PATCH 4/9] change in key from "Action" to "Actions" --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 2bf4fde..31ae9ed 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -820,7 +820,7 @@ } + (void)loadCallActions:(nonnull MVMCoreLoadObject *)loadObject { - NSDictionary *actionDict = [loadObject.responseJSON dict:@"Action"]; + NSDictionary *actionDict = [loadObject.responseJSON dict:@"Actions"]; if (actionDict) { //TODO needs to create operation queue based on concurrent flag //BOOL isConcurrent = [postCallsDict boolForKey:@"concurrent"]; From 8bceb77422369e20455d6dc85dc3645159151f84 Mon Sep 17 00:00:00 2001 From: Nishanth T Date: Tue, 3 Nov 2020 16:07:25 +0530 Subject: [PATCH 5/9] removed comments which are not needed for this implementation --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 31ae9ed..8399310 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -822,9 +822,6 @@ + (void)loadCallActions:(nonnull MVMCoreLoadObject *)loadObject { NSDictionary *actionDict = [loadObject.responseJSON dict:@"Actions"]; if (actionDict) { - //TODO needs to create operation queue based on concurrent flag - //BOOL isConcurrent = [postCallsDict boolForKey:@"concurrent"]; - //Needs further enhancements based on the flags. BOOL shouldTriggerFromCache = [actionDict boolForKey:@"shouldTriggerFromCache"]; //Check if page is not from cache if (!loadObject.pageDataFromCache || shouldTriggerFromCache) { From cc2783d3be503f03570d346fb0ea3ff37c18b8f2 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 3 Nov 2020 10:03:36 -0500 Subject: [PATCH 6/9] add comments --- .../MVMCoreViewControllerProgrammaticMappingObject.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h index fc03b06..b755710 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h @@ -10,14 +10,16 @@ @interface MVMCoreViewControllerProgrammaticMappingObject : NSObject -// View Controller Class, for loading by class. +/// View Controller Class, for loading by class. @property (nonnull, strong, nonatomic) Class viewControllerClass; +/// Configuration block executed on creation of the controller before loading. @property (nullable, copy, nonatomic) void (^configureHandler)(UIViewController * _Nonnull); -// Initializes with the given class. +/// Initializes with the given class. - (nullable id)initWithClass:(nonnull Class)viewControllerClass; +/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuraiton of the view controller before its loaded, i.e. injecting top level dependencies. - (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock; @end From ecbb9438bc02f5a2d67ea75c96e24ac65ce90068 Mon Sep 17 00:00:00 2001 From: Nishanth T Date: Tue, 3 Nov 2020 21:20:03 +0530 Subject: [PATCH 7/9] changes made in CoreLoadRequest passed delegate obj to PostAction removed flag and check changed Actions to PostAction --- .../MVMCoreLoadRequestOperation.m | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 8399310..4209310 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -779,12 +779,12 @@ if ([loadObject.operation checkAndHandleForCancellation]) { return; } - + DelegateObject *delegateObject = nil; // Show any alerts that we have been saving. if (loadObject.operation.alertToShow) { // If we have an alert to show and a loaded view controller, allow the loaded view controller to be the delegate. - DelegateObject *delegateObject = [loadedViewController respondsToSelector:@selector(delegateObject)] ? [loadedViewController delegateObject] : loadObject.operation.delegateObject; + delegateObject = [loadedViewController respondsToSelector:@selector(delegateObject)] ? [loadedViewController delegateObject] : loadObject.operation.delegateObject; [MVMCoreLoadRequestOperation createAndShowAlertForLoadObject:loadObject error:loadObject.operation.errorForAlertToShow delegateObject:delegateObject]; } @@ -796,9 +796,10 @@ } //make post load calls function - [MVMCoreLoadRequestOperation loadCallActions:loadObject]; + [MVMCoreLoadRequestOperation loadPostCallActions:loadObject]; + [MVMCoreLoadRequestOperation loadPostAction:loadObject delegateObject:delegateObject]; - [loadObject.operation markAsFinished]; + [loadObject.operation markAsFinished]; } @@ -819,14 +820,10 @@ } } -+ (void)loadCallActions:(nonnull MVMCoreLoadObject *)loadObject { - NSDictionary *actionDict = [loadObject.responseJSON dict:@"Actions"]; ++ (void)loadPostAction:(nonnull MVMCoreLoadObject *)loadObject delegateObject:(nullable DelegateObject *)delegateObject { + NSDictionary *actionDict = [loadObject.responseJSON dict:@"PostAction"]; if (actionDict) { - BOOL shouldTriggerFromCache = [actionDict boolForKey:@"shouldTriggerFromCache"]; - //Check if page is not from cache - if (!loadObject.pageDataFromCache || shouldTriggerFromCache) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionDict additionalData:nil delegateObject:nil]; - } + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionDict additionalData:nil delegateObject:delegateObject]; } } From edfdc8576cff6b62460415ed774d11a756e3880e Mon Sep 17 00:00:00 2001 From: Nishanth T Date: Tue, 3 Nov 2020 22:18:08 +0530 Subject: [PATCH 8/9] Update MVMCoreLoadRequestOperation.m indentation and lifted out delegate obj --- .../LoadHandling/MVMCoreLoadRequestOperation.m | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 4209310..b66c75a 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -779,12 +779,11 @@ if ([loadObject.operation checkAndHandleForCancellation]) { return; } - DelegateObject *delegateObject = nil; + + // If we have an alert to show and a loaded view controller, allow the loaded view controller to be the delegate. + DelegateObject *delegateObject = [loadedViewController respondsToSelector:@selector(delegateObject)] ? [loadedViewController delegateObject] : loadObject.operation.delegateObject; // Show any alerts that we have been saving. if (loadObject.operation.alertToShow) { - - // If we have an alert to show and a loaded view controller, allow the loaded view controller to be the delegate. - delegateObject = [loadedViewController respondsToSelector:@selector(delegateObject)] ? [loadedViewController delegateObject] : loadObject.operation.delegateObject; [MVMCoreLoadRequestOperation createAndShowAlertForLoadObject:loadObject error:loadObject.operation.errorForAlertToShow delegateObject:delegateObject]; } @@ -796,10 +795,10 @@ } //make post load calls function - [MVMCoreLoadRequestOperation loadPostCallActions:loadObject]; - [MVMCoreLoadRequestOperation loadPostAction:loadObject delegateObject:delegateObject]; + [MVMCoreLoadRequestOperation loadPostCallActions:loadObject]; + [MVMCoreLoadRequestOperation loadPostAction:loadObject delegateObject:delegateObject]; - [loadObject.operation markAsFinished]; + [loadObject.operation markAsFinished]; } From d62916510ae3b5b6a91005fba07475b9e23697d5 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 3 Nov 2020 12:11:43 -0500 Subject: [PATCH 9/9] typo --- .../MVMCoreViewControllerProgrammaticMappingObject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h index b755710..de0f25f 100644 --- a/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h +++ b/MVMCore/MVMCore/ViewControllerMapping/MVMCoreViewControllerProgrammaticMappingObject.h @@ -19,7 +19,7 @@ /// Initializes with the given class. - (nullable id)initWithClass:(nonnull Class)viewControllerClass; -/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuraiton of the view controller before its loaded, i.e. injecting top level dependencies. +/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuration of the view controller before its loaded, i.e. injecting top level dependencies. - (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock; @end