Skip to content

Commit

Permalink
Fix crash for bloks sidebar
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Luke De Feo authored and facebook-github-bot committed Sep 15, 2023
1 parent 21b4423 commit 237fadd
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
})}
Expand Down Expand Up @@ -122,7 +121,7 @@ function create(
inspectable: Inspectable,
level: number = 2,
) {
switch (inspectable.type) {
switch (inspectable?.type) {
case 'boolean':
return (
<NamedAttributeInspector name={displayableName(name)}>
Expand Down

0 comments on commit 237fadd

Please sign in to comment.