summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLPreloadChoicesOperation.m
diff options
context:
space:
mode:
authorJustin Gluck <justin.gluck@livio.io>2019-04-05 15:56:39 -0400
committerJustin Gluck <justin.gluck@livio.io>2019-04-05 15:56:39 -0400
commit46aadf5d892176162e8ebb2f3653b24de26c8d06 (patch)
treef977e35876a6f72d911329df495a31544f56e12c /SmartDeviceLink/SDLPreloadChoicesOperation.m
parent583cde91ea6868a03b05b49e48771f9016413c32 (diff)
downloadsdl_ios-46aadf5d892176162e8ebb2f3653b24de26c8d06.tar.gz
WIP : If menueName is nil we do not want to send a RPC since menuName is a required field to send an RPC
Diffstat (limited to 'SmartDeviceLink/SDLPreloadChoicesOperation.m')
-rw-r--r--SmartDeviceLink/SDLPreloadChoicesOperation.m22
1 files changed, 18 insertions, 4 deletions
diff --git a/SmartDeviceLink/SDLPreloadChoicesOperation.m b/SmartDeviceLink/SDLPreloadChoicesOperation.m
index 1e9be8ec9..e3fb78cd4 100644
--- a/SmartDeviceLink/SDLPreloadChoicesOperation.m
+++ b/SmartDeviceLink/SDLPreloadChoicesOperation.m
@@ -118,9 +118,18 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableArray<SDLCreateInteractionChoiceSet *> *choiceRPCs = [NSMutableArray arrayWithCapacity:self.cellsToUpload.count];
for (SDLChoiceCell *cell in self.cellsToUpload) {
- [choiceRPCs addObject:[self sdl_choiceFromCell:cell]];
+ SDLCreateInteractionChoiceSet *csCell = [self sdl_choiceFromCell:cell];
+ if(csCell != nil) {
+ [choiceRPCs addObject:csCell];
+ }
}
-
+
+ if (choiceRPCs.count == 0) {
+ SDLLogE(@"Error choiceRPCs is an empty array");
+ self.internalError = [NSError sdl_choiceSetManager_failedToCreateMenuItems];
+ [self finishOperation];
+ }
+
__weak typeof(self) weakSelf = self;
__block NSMutableDictionary<SDLRPCRequest *, NSError *> *errors = [NSMutableDictionary dictionary];
[self.connectionManager sendRequests:[choiceRPCs copy] progressHandler:^(__kindof SDLRPCRequest * _Nonnull request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error, float percentComplete) {
@@ -141,7 +150,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Assembling Choice Data
-- (SDLCreateInteractionChoiceSet *)sdl_choiceFromCell:(SDLChoiceCell *)cell {
+- (SDLCreateInteractionChoiceSet * _Nullable )sdl_choiceFromCell:(SDLChoiceCell *)cell {
NSArray<NSString *> *vrCommands = nil;
if (cell.voiceCommands == nil) {
vrCommands = self.isVROptional ? nil : @[[NSString stringWithFormat:@"%hu", cell.choiceId]];
@@ -149,7 +158,12 @@ NS_ASSUME_NONNULL_BEGIN
vrCommands = cell.voiceCommands;
}
- NSString *menuName = [self.displayCapabilities hasTextFieldOfName:SDLTextFieldNameMenuName] ? cell.text : nil;
+ NSString *menuName = [self.displayCapabilities hasTextFieldOfName:SDLTextFieldNameMenuName] ? cell.text : nil;
+
+ if(!menuName) {
+ return nil;
+ }
+
NSString *secondaryText = [self.displayCapabilities hasTextFieldOfName:SDLTextFieldNameSecondaryText] ? cell.secondaryText : nil;
NSString *tertiaryText = [self.displayCapabilities hasTextFieldOfName:SDLTextFieldNameTertiaryText] ? cell.tertiaryText : nil;