Skip to content

Commit

Permalink
Add LithoVisibilityEventsController
Browse files Browse the repository at this point in the history
Summary: Added a quick way to see if there is a LithoVisibilityEventsController set to a Component Tree

Reviewed By: adityasharat

Differential Revision: D65483784

fbshipit-source-id: cdbe55ed62fe3e20c1903ec09d8176e5315425af
  • Loading branch information
jettbow authored and facebook-github-bot committed Nov 6, 2024
1 parent c78fa8c commit 8694713
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class ComponentTreeDescriptor(val register: DescriptorRegister) : NodeDescriptor
private val ComponentTreeId =
MetadataRegister.register(MetadataRegister.TYPE_ATTRIBUTE, "treeConfiguration", "id")

private val LithoVisibilityEventsControllerId =
MetadataRegister.register(
MetadataRegister.TYPE_ATTRIBUTE, NAMESPACE, "LithoVisibilityEventsController")

private val qualifiedName = ComponentTree::class.qualifiedName ?: ""

override fun getId(node: ComponentTree): Id = node.id
Expand Down Expand Up @@ -83,10 +87,28 @@ class ComponentTreeDescriptor(val register: DescriptorRegister) : NodeDescriptor
attributeSections[ConfigurationSectionId] =
InspectableObject(getLithoConfigurationAttributes(node))

attributeSections[LithoVisibilityEventsControllerId] =
InspectableObject(getLithoVisibilityEventsControllerAttributes(node))

attributeSections
}
}

private fun getLithoVisibilityEventsControllerAttributes(
tree: ComponentTree
): Map<MetadataId, Inspectable> {
val lithoVisibilityEventsController = tree.getLithoVisibilityEventsController()
val metadataId =
MetadataRegister.register(
MetadataRegister.TYPE_ATTRIBUTE,
"LithoVisibilityEventsController",
"LithoVisibilityEventsController")

return mapOf(
metadataId to
InspectableValue.Unknown(lithoVisibilityEventsController?.toString() ?: "null"))
}

private fun getLithoConfigurationAttributes(tree: ComponentTree): Map<MetadataId, Inspectable> {
val (configurationInstance, configurationFields) =
getConfigurationFieldsAndValuesUsingReflection(tree)
Expand Down

0 comments on commit 8694713

Please sign in to comment.