summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-11-10 12:39:58 -0500
committerJoel Fischer <joeljfischer@gmail.com>2020-11-10 12:39:58 -0500
commit0ff8887499cf489f09c3b3feda9255d8cf587306 (patch)
treea9a2346068092f4dcc1d479010371133200272b0
parent269e03e32caf7d4b5b30db0d23b7295bcad3d980 (diff)
downloadsdl_ios-0ff8887499cf489f09c3b3feda9255d8cf587306.tar.gz
Fix manager not updating newer operations with new current data
-rw-r--r--SmartDeviceLink/SDLVoiceCommandUpdateOperation.h2
-rw-r--r--SmartDeviceLink/SDLVoiceCommandUpdateOperation.m3
-rw-r--r--SmartDeviceLink/private/SDLVoiceCommandManager.m10
3 files changed, 14 insertions, 1 deletions
diff --git a/SmartDeviceLink/SDLVoiceCommandUpdateOperation.h b/SmartDeviceLink/SDLVoiceCommandUpdateOperation.h
index b9b09f3db..dae970988 100644
--- a/SmartDeviceLink/SDLVoiceCommandUpdateOperation.h
+++ b/SmartDeviceLink/SDLVoiceCommandUpdateOperation.h
@@ -18,6 +18,8 @@ typedef void(^SDLVoiceCommandUpdateCompletionHandler)(NSArray<SDLVoiceCommand *>
@interface SDLVoiceCommandUpdateOperation : SDLAsynchronousOperation
+@property (strong, nonatomic, nullable) NSArray<SDLVoiceCommand *> *currentVoiceCommands;
+
- (instancetype)initWithConnectionManager:(id<SDLConnectionManagerType>)connectionManager newVoiceCommands:(nullable NSArray<SDLVoiceCommand *> *)newVoiceCommands oldVoiceCommands:(nullable NSArray<SDLVoiceCommand *> *)oldVoiceCommands updateCompletionHandler:(SDLVoiceCommandUpdateCompletionHandler)completionHandler;
@end
diff --git a/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m b/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m
index 2ad35d68d..a3c8b49e6 100644
--- a/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m
+++ b/SmartDeviceLink/SDLVoiceCommandUpdateOperation.m
@@ -18,14 +18,15 @@
NS_ASSUME_NONNULL_BEGIN
@interface SDLVoiceCommand()
+
@property (assign, nonatomic) UInt32 commandId;
+
@end
@interface SDLVoiceCommandUpdateOperation ()
@property (weak, nonatomic) id<SDLConnectionManagerType> connectionManager;
@property (strong, nonatomic, nullable) NSArray<SDLVoiceCommand *> *updatedVoiceCommands;
-@property (strong, nonatomic, nullable) NSArray<SDLVoiceCommand *> *currentVoiceCommands;
@property (copy, nonatomic) SDLVoiceCommandUpdateCompletionHandler completionHandler;
@property (copy, nonatomic, nullable) NSError *internalError;
diff --git a/SmartDeviceLink/private/SDLVoiceCommandManager.m b/SmartDeviceLink/private/SDLVoiceCommandManager.m
index caedc82d8..4900acfad 100644
--- a/SmartDeviceLink/private/SDLVoiceCommandManager.m
+++ b/SmartDeviceLink/private/SDLVoiceCommandManager.m
@@ -120,12 +120,22 @@ UInt32 const VoiceCommandIdMin = 1900000000;
__weak typeof(self) weakSelf = self;
SDLVoiceCommandUpdateOperation *updateOperation = [[SDLVoiceCommandUpdateOperation alloc] initWithConnectionManager:self.connectionManager newVoiceCommands:voiceCommands oldVoiceCommands:_currentVoiceCommands updateCompletionHandler:^(NSArray<SDLVoiceCommand *> *newCurrentVoiceCommands, NSError * _Nullable error) {
weakSelf.currentVoiceCommands = newCurrentVoiceCommands;
+ [weakSelf sdl_updatePendingOperationsWithNewCurrentVoiceCommands:newCurrentVoiceCommands];
}];
[self.transactionQueue cancelAllOperations];
[self.transactionQueue addOperation:updateOperation];
}
+- (void)sdl_updatePendingOperationsWithNewCurrentVoiceCommands:(NSArray<SDLVoiceCommand *> *)currentVoiceCommands {
+ for (NSOperation *operation in self.transactionQueue.operations) {
+ if (operation.isExecuting) { continue; }
+ SDLVoiceCommandUpdateOperation *updateOp = (SDLVoiceCommandUpdateOperation *)operation;
+
+ updateOp.currentVoiceCommands = currentVoiceCommands;
+ }
+}
+
#pragma mark - Helpers
#pragma mark IDs