Fix crash for bloks sidebar

Summary: Bloks ios is serializing some ns dictionary without registering the metadata, this means the look up fails. That said regsitering metadata for dictionarys where the keyspace is unbounded doesnt make any sense so for this case we can just fall back to the key as the name. Since we can rely on the id lookup passing we iterarates the enties of the object

Reviewed By: passy, ivanmisuno

Differential Revision: D49314398

fbshipit-source-id: 65f7beb0d8402b08a68b9f00b7605e0b6c44766f
This commit is contained in:
Luke De Feo
2023-09-15 04:05:43 -07:00
committed by Facebook GitHub Bot
parent 21b4423231
commit 237faddb40

View File

@@ -72,17 +72,16 @@ const ObjectAttributeInspector: React.FC<{
return (
<div style={RowStyle}>
{name}
{Object.keys(fields).map(function (key, _) {
{Object.entries(fields).map(([key, value]) => {
const metadataId: number = Number(key);
const inspectableValue = fields[metadataId];
const attributeName = metadata.get(metadataId)?.name ?? '';
const attributeName = metadata.get(metadataId)?.name ?? key;
return (
<ObjectContainer
key={metadataId}
style={{
paddingLeft: level,
}}>
{create(metadata, attributeName, inspectableValue, level + 5)}
{create(metadata, attributeName, value, level + 5)}
</ObjectContainer>
);
})}
@@ -122,7 +121,7 @@ function create(
inspectable: Inspectable,
level: number = 2,
) {
switch (inspectable.type) {
switch (inspectable?.type) {
case 'boolean':
return (
<NamedAttributeInspector name={displayableName(name)}>