From 20d9261cb3d9e3ff746f5c745acee7228c33319f Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Mon, 6 Aug 2018 17:52:17 -0400 Subject: [PATCH 1/3] Allow the server to specify whether to extend the session timer. --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h | 2 ++ MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m | 6 ++++++ MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h index dfe6705..dbaee70 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h @@ -48,6 +48,8 @@ @property (nonatomic) BOOL pageDataFromCache; @property (nonatomic) BOOL moduleDataFromCache; +@property (nonatomic, readonly) BOOL extendsAppSession; + - (nullable instancetype)initWithPageJSON:(nullable NSDictionary *)pageJSON modulesJSON:(nullable NSDictionary *)modulesJSON requestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject*)delegate; - (nullable instancetype)initWithRequestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject*)delegate; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m index 3064012..01fd7cf 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m @@ -9,6 +9,7 @@ #import "MVMCoreLoadObject.h" #import "MVMCoreErrorObject.h" #import "MVMCoreJSONConstants.h" +#import "NSDictionary+MFConvenience.h" @implementation MVMCoreLoadObject @@ -54,4 +55,9 @@ return self; } +- (BOOL) extendsAppSession { + NSNumber *extendSessionFlag = [self.responseInfoMap objectForKey:@"appSessionExtended" ofType:[NSNumber class]]; + return !extendSessionFlag || [extendSessionFlag boolValue]; // Default to YES if the key does not exist. +} + @end diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 7c919b1..020d724 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -284,7 +284,9 @@ if ([jsonObject isKindOfClass:[NSDictionary class]]) { // Update the session timer on a good response. - [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; + if (loadObject.extendsAppSession) { + [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; + } completionHandler(jsonObject); } else { From 5e5cb1a5525f7c3cba75650ba177304c0fa14d40 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Tue, 7 Aug 2018 12:21:15 -0400 Subject: [PATCH 2/3] Adjust timing of session timer extension. PR resolution. --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h | 5 +++-- MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m | 2 +- .../LoadHandling/MVMCoreLoadRequestOperation.m | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h index dbaee70..014e4ba 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h @@ -48,8 +48,6 @@ @property (nonatomic) BOOL pageDataFromCache; @property (nonatomic) BOOL moduleDataFromCache; -@property (nonatomic, readonly) BOOL extendsAppSession; - - (nullable instancetype)initWithPageJSON:(nullable NSDictionary *)pageJSON modulesJSON:(nullable NSDictionary *)modulesJSON requestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject*)delegate; - (nullable instancetype)initWithRequestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegate:(nullable NSObject*)delegate; @@ -58,4 +56,7 @@ - (nullable instancetype)initWithPageJSON:(nullable NSDictionary *)pageJSON errorObject:(nullable MVMCoreErrorObject *)errorObject; +// Returns whether the load will extend the app session timer based on the response provided by the server. +- (BOOL)extendsAppSession; + @end diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m index 01fd7cf..388f911 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.m @@ -55,7 +55,7 @@ return self; } -- (BOOL) extendsAppSession { +- (BOOL)extendsAppSession { NSNumber *extendSessionFlag = [self.responseInfoMap objectForKey:@"appSessionExtended" ofType:[NSNumber class]]; return !extendSessionFlag || [extendSessionFlag boolValue]; // Default to YES if the key does not exist. } diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 020d724..f525969 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -164,6 +164,11 @@ return; } + // Update the session timer on a good response. + if (loadObject.extendsAppSession) { + [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; + } + if (loadObject.pageDataFromCache || loadObject.pageType) { // Can continue loading with the page. @@ -283,12 +288,8 @@ if ([jsonObject isKindOfClass:[NSDictionary class]]) { - // Update the session timer on a good response. - if (loadObject.extendsAppSession) { - [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; - } - completionHandler(jsonObject); + } else { // Error json not correct format. From 098aded7edbe0159f51e4bce236c41f445288dd2 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Thu, 9 Aug 2018 11:21:57 -0400 Subject: [PATCH 3/3] More aggressive session extension. --- .../MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index f525969..b01a990 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -163,11 +163,6 @@ if ([loadObject.operation checkAndHandleForCancellation]) { return; } - - // Update the session timer on a good response. - if (loadObject.extendsAppSession) { - [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; - } if (loadObject.pageDataFromCache || loadObject.pageType) { @@ -368,6 +363,11 @@ // Sets the response info map loadObject.responseInfoMap = [jsonDictionary dict:KeyResponseInfo]; + // Update the session timer on a good response. + if (loadObject.extendsAppSession) { + [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; + } + // Dismiss any top alerts that server wants us to dismiss [[MVMCoreAlertHandler sharedAlertHandler] hidePersistentTopAlertViewOfType:[loadObject.responseInfoMap string:@"disableType"]];