diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h index dfe6705..014e4ba 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h @@ -56,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 3064012..388f911 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..b01a990 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -163,7 +163,7 @@ if ([loadObject.operation checkAndHandleForCancellation]) { return; } - + if (loadObject.pageDataFromCache || loadObject.pageType) { // Can continue loading with the page. @@ -283,10 +283,8 @@ if ([jsonObject isKindOfClass:[NSDictionary class]]) { - // Update the session timer on a good response. - [[MVMCoreSessionTimeHandler sharedSessionHandler] startSessionTimer]; - completionHandler(jsonObject); + } else { // Error json not correct format. @@ -365,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"]];