Start sending parent id
Summary: Since subtree update is effectively a frame dump its a lot easier to send the parent ID. This will save having figure it out on the client which is somewhat expensive and is needed for bloks Reviewed By: lblasa Differential Revision: D45048023 fbshipit-source-id: 90c4888df063de0aa69c9b93c86d9891e30becbe
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3cec113b0e
commit
eee74044ff
@@ -12,6 +12,7 @@ import com.facebook.flipper.plugins.uidebugger.descriptors.Id
|
||||
@kotlinx.serialization.Serializable
|
||||
data class Node(
|
||||
val id: Id,
|
||||
val parent: Id?,
|
||||
val qualifiedName: String,
|
||||
val name: String,
|
||||
val attributes: Map<MetadataId, InspectableObject>,
|
||||
|
||||
@@ -36,13 +36,14 @@ class PartialLayoutTraversal(
|
||||
val visited = mutableListOf<MaybeDeferred<Node>>()
|
||||
val observableRoots = mutableListOf<Any>()
|
||||
|
||||
val stack = mutableListOf<Any>()
|
||||
stack.add(root)
|
||||
// cur and parent Id
|
||||
val stack = mutableListOf<Pair<Any, Id?>>()
|
||||
stack.add(Pair(root, null))
|
||||
|
||||
val shallow = mutableSetOf<Any>()
|
||||
|
||||
while (stack.isNotEmpty()) {
|
||||
val node = stack.removeLast()
|
||||
val (node, parentId) = stack.removeLast()
|
||||
|
||||
try {
|
||||
// If we encounter a node that has it own observer, don't traverse
|
||||
@@ -53,11 +54,13 @@ class PartialLayoutTraversal(
|
||||
|
||||
val descriptor = descriptorRegister.descriptorForClassUnsafe(node::class.java).asAny()
|
||||
|
||||
val curId = descriptor.getId(node)
|
||||
if (shallow.contains(node)) {
|
||||
visited.add(
|
||||
Immediate(
|
||||
Node(
|
||||
descriptor.getId(node),
|
||||
curId,
|
||||
parentId,
|
||||
descriptor.getQualifiedName(node),
|
||||
descriptor.getName(node),
|
||||
emptyMap(),
|
||||
@@ -86,7 +89,7 @@ class PartialLayoutTraversal(
|
||||
children.forEach { child ->
|
||||
val childDescriptor = descriptorRegister.descriptorForClassUnsafe(child.javaClass)
|
||||
childrenIds.add(childDescriptor.getId(child))
|
||||
stack.add(child)
|
||||
stack.add(Pair(child, curId))
|
||||
// If there is an active child then don't traverse it
|
||||
if (activeChild != null && activeChild != child) {
|
||||
shallow.add(child)
|
||||
@@ -99,7 +102,8 @@ class PartialLayoutTraversal(
|
||||
visited.add(
|
||||
attributes.map { attrs ->
|
||||
Node(
|
||||
descriptor.getId(node),
|
||||
curId,
|
||||
parentId,
|
||||
descriptor.getQualifiedName(node),
|
||||
descriptor.getName(node),
|
||||
attrs,
|
||||
|
||||
Reference in New Issue
Block a user