From cf1347d2e313f8e458e964824bd8f750de07a52b Mon Sep 17 00:00:00 2001 From: Roman Gorbunov Date: Wed, 10 Jul 2019 06:59:45 -0700 Subject: [PATCH] Fixed bug with flipper live editing Summary: Fixed bug with live editing Previously if the meaining of the value was changed in flipper you receive back same value as it was Now you see correct changed value Reviewed By: priteshrnandgaonkar Differential Revision: D16162141 fbshipit-source-id: 1a68ea64603171e952382c5093470d2cc12f7bbe --- .../FlipperKitLayoutPlugin.mm | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.mm index 1a64f07a6..d1a4c9774 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.mm +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.mm @@ -86,7 +86,7 @@ [connection receive:@"getRoot" withBlock:^(NSDictionary *params, id responder) { FlipperPerformBlockOnMainThread(^{ [weakSelf onCallGetRoot: responder]; }, responder); }]; - + [connection receive:@"getAllNodes" withBlock:^(NSDictionary *params, id responder) { FlipperPerformBlockOnMainThread(^{ [weakSelf onCallGetAllNodesWithResponder: responder]; }, responder); }]; @@ -161,6 +161,19 @@ [responder success:@{@"allNodes": @{@"rootElement": identifier, @"elements": allNodesDict}}]; } +- (NSMutableArray*)getChildrenForNode:(id)node withDescriptor:(SKNodeDescriptor*)descriptor { + NSMutableArray *children = [NSMutableArray new]; + for (NSUInteger i = 0; i < [descriptor childCountForNode: node]; i++) { + id childNode = [descriptor childForNode: node atIndex: i]; + + NSString *childIdentifier = [self trackObject: childNode]; + if (childIdentifier) { + [children addObject: childIdentifier]; + } + } + return children; +} + - (void)onCallGetNodes:(NSArray *)nodeIds withResponder:(id)responder { NSMutableArray *elements = [NSMutableArray new]; @@ -201,7 +214,11 @@ SKNodeUpdateData updateDataForPath = [[descriptor dataMutationsForNode: node] objectForKey: dotJoinedPath]; if (updateDataForPath != nil) { updateDataForPath(value); - [connection send: @"invalidate" withParams: @{ @"id": [descriptor identifierForNode: node] }]; + + NSMutableArray *children = [self getChildrenForNode:node withDescriptor:descriptor]; + [connection send: @"invalidate" withParams: @{ + @"nodes": @[@{@"id": [descriptor identifierForNode: node], @"children": children}] + }]; } } @@ -405,15 +422,7 @@ data[namedPair.name] = namedPair.value; } - NSMutableArray *children = [NSMutableArray new]; - for (NSUInteger i = 0; i < [nodeDescriptor childCountForNode: node]; i++) { - id childNode = [nodeDescriptor childForNode: node atIndex: i]; - - NSString *childIdentifier = [self trackObject: childNode]; - if (childIdentifier) { - [children addObject: childIdentifier]; - } - } + NSMutableArray *children = [self getChildrenForNode: node withDescriptor:nodeDescriptor]; NSDictionary *nodeDic = @{