Merge branch 'bugfix/molecules' into 'develop'

Moved required module checking to the view controller where it belongs.

See merge request BPHV_MIPS/mvm_core!19
This commit is contained in:
Pfeil, Scott Robert 2019-06-28 15:28:39 -04:00
commit b2484bd852
2 changed files with 2 additions and 49 deletions

View File

@ -73,13 +73,6 @@
* @return True if the calling process should continue. */
+ (BOOL)cachePages:(nullable NSDictionary *)pages loadObject:(nonnull MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error;
/** Verifies that all needed modules are loaded
* @param viewController The view controller going to be loaded.
* @param loadObject The load data from the cache or server.
* @param error The error object passed in will be set in the case of an error.
* @return True if the calling process should continue. */
+ (BOOL)verifyRequiredModulesLoaded:(nonnull UIViewController <MVMCoreViewControllerProtocol> *)viewController loadObject:(nullable MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error;
/** Creates the view controller based on the load object passed in.
* @param loadObject The load data from the cache or server.
* @param completionHandler The completion handler to load once finished. Returns any loaded view controller and the load.*/

View File

@ -674,39 +674,6 @@
return shouldContinue;
}
+ (BOOL)verifyRequiredModulesLoaded:(nonnull UIViewController <MVMCoreViewControllerProtocol> *)viewController loadObject:(nullable MVMCoreLoadObject *)loadObject error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error {
// Check if all needed modules are loaded.
__block NSMutableArray *modulesRequired = [NSMutableArray arrayWithArray:[[MVMCoreViewControllerMappingObject sharedViewControllerMappingObject] modulesRequiredForPageType:loadObject.pageType]];
if (modulesRequired.count > 0) {
[[loadObject.modulesJSON allKeys] enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (modulesRequired.count == 0) {
*stop = YES;
} else {
NSUInteger index = [modulesRequired indexOfObject:obj];
if (index != NSNotFound) {
[modulesRequired removeObjectAtIndex:index];
}
}
}];
if (modulesRequired.count == 0) {
return YES;
} else {
// Error, not all needed modules are loaded.
if (error) {
*error = [[MVMCoreErrorObject alloc] initWithTitle:nil message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorCritical] messageToLog:[modulesRequired description] code:ErrorCodeRequiredModuleNotPresent domain:ErrorDomainNative location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
}
return NO;
}
} else {
return YES;
}
}
+ (void)createViewControllerWithLoadObject:(nonnull MVMCoreLoadObject *)loadObject completionHandler:(nonnull void (^)(UIViewController <MVMCoreViewControllerProtocol> * _Nullable viewController, MVMCoreLoadObject *_Nonnull loadObject))completionHandler {
if ([loadObject.operation checkAndHandleForCancellation]) {
@ -732,17 +699,10 @@
BOOL shouldContinue = NO;
if (viewController) {
// Verifies all modules needed are loaded.
shouldContinue = [MVMCoreLoadRequestOperation verifyRequiredModulesLoaded:viewController loadObject:loadObject error:&error];
// Allows the view controller to handle specific errors (such as ensure it has all the required data).
shouldContinue = [viewController shouldFinishProcessingLoad:loadObject error:&error];
if (!shouldContinue) {
viewController = nil;
} else {
// Allows the view controller to handle specific errors (such as if certain data that it needs isn't loaded).
shouldContinue = [viewController shouldFinishProcessingLoad:loadObject error:&error];
if (!shouldContinue) {
viewController = nil;
}
}
} else {
// Couldn't initialize view controller, serious error.