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
|
@kotlinx.serialization.Serializable
|
||||||
data class Node(
|
data class Node(
|
||||||
val id: Id,
|
val id: Id,
|
||||||
|
val parent: Id?,
|
||||||
val qualifiedName: String,
|
val qualifiedName: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
val attributes: Map<MetadataId, InspectableObject>,
|
val attributes: Map<MetadataId, InspectableObject>,
|
||||||
|
|||||||
@@ -36,13 +36,14 @@ class PartialLayoutTraversal(
|
|||||||
val visited = mutableListOf<MaybeDeferred<Node>>()
|
val visited = mutableListOf<MaybeDeferred<Node>>()
|
||||||
val observableRoots = mutableListOf<Any>()
|
val observableRoots = mutableListOf<Any>()
|
||||||
|
|
||||||
val stack = mutableListOf<Any>()
|
// cur and parent Id
|
||||||
stack.add(root)
|
val stack = mutableListOf<Pair<Any, Id?>>()
|
||||||
|
stack.add(Pair(root, null))
|
||||||
|
|
||||||
val shallow = mutableSetOf<Any>()
|
val shallow = mutableSetOf<Any>()
|
||||||
|
|
||||||
while (stack.isNotEmpty()) {
|
while (stack.isNotEmpty()) {
|
||||||
val node = stack.removeLast()
|
val (node, parentId) = stack.removeLast()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// If we encounter a node that has it own observer, don't traverse
|
// 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 descriptor = descriptorRegister.descriptorForClassUnsafe(node::class.java).asAny()
|
||||||
|
|
||||||
|
val curId = descriptor.getId(node)
|
||||||
if (shallow.contains(node)) {
|
if (shallow.contains(node)) {
|
||||||
visited.add(
|
visited.add(
|
||||||
Immediate(
|
Immediate(
|
||||||
Node(
|
Node(
|
||||||
descriptor.getId(node),
|
curId,
|
||||||
|
parentId,
|
||||||
descriptor.getQualifiedName(node),
|
descriptor.getQualifiedName(node),
|
||||||
descriptor.getName(node),
|
descriptor.getName(node),
|
||||||
emptyMap(),
|
emptyMap(),
|
||||||
@@ -86,7 +89,7 @@ class PartialLayoutTraversal(
|
|||||||
children.forEach { child ->
|
children.forEach { child ->
|
||||||
val childDescriptor = descriptorRegister.descriptorForClassUnsafe(child.javaClass)
|
val childDescriptor = descriptorRegister.descriptorForClassUnsafe(child.javaClass)
|
||||||
childrenIds.add(childDescriptor.getId(child))
|
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 there is an active child then don't traverse it
|
||||||
if (activeChild != null && activeChild != child) {
|
if (activeChild != null && activeChild != child) {
|
||||||
shallow.add(child)
|
shallow.add(child)
|
||||||
@@ -99,7 +102,8 @@ class PartialLayoutTraversal(
|
|||||||
visited.add(
|
visited.add(
|
||||||
attributes.map { attrs ->
|
attributes.map { attrs ->
|
||||||
Node(
|
Node(
|
||||||
descriptor.getId(node),
|
curId,
|
||||||
|
parentId,
|
||||||
descriptor.getQualifiedName(node),
|
descriptor.getQualifiedName(node),
|
||||||
descriptor.getName(node),
|
descriptor.getName(node),
|
||||||
attrs,
|
attrs,
|
||||||
|
|||||||
Reference in New Issue
Block a user