From 985d01842d273930ca719fac293a51627615d6fc Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 31 Jul 2023 16:54:17 -0400 Subject: [PATCH] Hardcoded response testing. --- .../LoadHandling/MVMCoreLoadRequestOperation.m | 14 ++++++++++++++ .../MainProtocols/MVMCoreGlobalLoadProtocol.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index dd5b822..7618fae 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -167,6 +167,12 @@ // Send a new request to the server. [MVMCoreLoadRequestOperation sendRequest:requestForMissingData loadObject:loadObject completionHandler:^(NSDictionary * _Nullable json) { +#if ENABLE_HARD_CODED_RESPONSE + if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(modifyJSON:)]) { + json = [[MVMCoreObject sharedInstance].globalLoadDelegate modifyJSON:json]; + } +#endif + NSString *serverProcessTime = [(NSDictionary *)json objectChainOfKeysOrIndexes:@[@"ResponseInfo", @"timeStamp"]] ?: @"0"; if(!self.backgroundLoad && loadObject.requestParameters.pageType && serverProcessTime) { @@ -291,6 +297,14 @@ return; } +#if ENABLE_HARD_CODED_RESPONSE + if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getJSONForPageType:)]) { + NSDictionary *json = [[MVMCoreObject sharedInstance].globalLoadDelegate getJSONForPageType:requestParameters.pageType]; + completionHandler(json); + return; + } +#endif + loadObject.operation.sessionTask = [[MVMCoreLoadHandler sharedGlobal] sendRequest:requestParameters locationForError:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject] requestFinished:^(id jsonObject, MVMCoreErrorObject *error) { if ([loadObject.operation checkAndHandleForCancellation]) { diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h index 65ea153..938b13c 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h @@ -41,4 +41,9 @@ /// Checks to see if the operation has content to show. - (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; +#if ENABLE_HARD_CODED_RESPONSE +- (nonnull NSDictionary *)getJSONForPageType:(nonnull NSString *)pageType; +- (nonnull NSDictionary *)modifyJSON:(nonnull NSDictionary *)json; +#endif + @end