From 976c3a3e7a6179227bb0ce8c57025099b4e175c3 Mon Sep 17 00:00:00 2001 From: Ramya Subramaniam Date: Thu, 6 Jun 2019 18:38:50 +0530 Subject: [PATCH 1/5] Post call actions added --- .../MVMCoreLoadRequestOperation.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 18576ec..22be088 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -845,9 +845,28 @@ } else { [MVMCoreLoggingHandler logWithDelegateLoadFinished:loadObject loadedViewController:loadedViewController error:errorObject]; } + + //make post load calls function + [MVMCoreLoadRequestOperation loadPostCallActions:loadObject]; + [loadObject.operation markAsFinished]; } + ++ (void)loadPostCallActions:(nonnull MVMCoreLoadObject *)loadObject { + NSDictionary *postCallsDict = [loadObject.pageJSON dictionaryForKey:@"postLoadActions"]; + if (postCallsDict.count > 0) { + NSArray *actionList = [postCallsDict arrayForKey:@"actionList"]; + BOOL isConcurrent = [postCallsDict boolForKey:@"concurrent"]; + //Needs further enhancements based on the flags. + if (isConcurrent) { + [actionList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:obj additionalData:nil delegateObject:nil]; + }]; + } + } +} + #pragma mark - Presentation Delegate - (void)navigationController:(UINavigationController *)navigationController willDisplayViewController:(UIViewController *)viewController { From 752d9461e67a1dc8eb70d93c952e1c8b0dd30833 Mon Sep 17 00:00:00 2001 From: "Subramaniam, Ramya" Date: Mon, 10 Jun 2019 19:14:17 +0530 Subject: [PATCH 2/5] Updating review comments --- .../MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 22be088..ce35730 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -854,12 +854,14 @@ + (void)loadPostCallActions:(nonnull MVMCoreLoadObject *)loadObject { - NSDictionary *postCallsDict = [loadObject.pageJSON dictionaryForKey:@"postLoadActions"]; - if (postCallsDict.count > 0) { - NSArray *actionList = [postCallsDict arrayForKey:@"actionList"]; + NSDictionary *postCallsDict = [loadObject.pageJSON dict:@"postLoadActions"]; + if (postCallsDict) { + NSArray *actionList = [postCallsDict array:@"actionList"]; BOOL isConcurrent = [postCallsDict boolForKey:@"concurrent"]; //Needs further enhancements based on the flags. - if (isConcurrent) { + BOOL shouldTriggerFromCache = [postCallsDict boolForKey:@"shouldTriggerFromCache"]; + //Check if page is not from cache + if (!shouldTriggerFromCache && !loadObject.pageDataFromCache) { [actionList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:obj additionalData:nil delegateObject:nil]; }]; From 586486004514323a942a39448d94c79d7d9fca3c Mon Sep 17 00:00:00 2001 From: "Subramaniam, Ramya" Date: Mon, 10 Jun 2019 19:17:18 +0530 Subject: [PATCH 3/5] updating review comments --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index ce35730..00d94fd 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -857,6 +857,7 @@ NSDictionary *postCallsDict = [loadObject.pageJSON dict:@"postLoadActions"]; if (postCallsDict) { NSArray *actionList = [postCallsDict array:@"actionList"]; + //TODO needs to create operation queue based on concurrent flag BOOL isConcurrent = [postCallsDict boolForKey:@"concurrent"]; //Needs further enhancements based on the flags. BOOL shouldTriggerFromCache = [postCallsDict boolForKey:@"shouldTriggerFromCache"]; @@ -866,6 +867,7 @@ [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:obj additionalData:nil delegateObject:nil]; }]; } + //Needs to handle when page is from cache. } } From 262f9c9d5b5ac4826f504a959c603497e6f323cb Mon Sep 17 00:00:00 2001 From: "Subramaniam, Ramya" Date: Mon, 10 Jun 2019 21:40:36 +0530 Subject: [PATCH 4/5] Updating page cache scenario --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 00d94fd..6c4aebe 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -862,12 +862,11 @@ //Needs further enhancements based on the flags. BOOL shouldTriggerFromCache = [postCallsDict boolForKey:@"shouldTriggerFromCache"]; //Check if page is not from cache - if (!shouldTriggerFromCache && !loadObject.pageDataFromCache) { + if (!loadObject.pageDataFromCache || (shouldTriggerFromCache && loadObject.pageDataFromCache)) { [actionList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:obj additionalData:nil delegateObject:nil]; }]; } - //Needs to handle when page is from cache. } } From 1b2dc9281aaa7a2be85d8da4806b6a8b864fa760 Mon Sep 17 00:00:00 2001 From: "Subramaniam, Ramya" Date: Thu, 13 Jun 2019 00:05:34 +0530 Subject: [PATCH 5/5] Updated review comments --- 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 6c4aebe..0ac97e4 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -862,7 +862,7 @@ //Needs further enhancements based on the flags. BOOL shouldTriggerFromCache = [postCallsDict boolForKey:@"shouldTriggerFromCache"]; //Check if page is not from cache - if (!loadObject.pageDataFromCache || (shouldTriggerFromCache && loadObject.pageDataFromCache)) { + if (!loadObject.pageDataFromCache || shouldTriggerFromCache) { [actionList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:obj additionalData:nil delegateObject:nil]; }];