Skip to content

Commit

Permalink
changed blockdetails logic to determine when to re-render
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Robert Tester committed Sep 27, 2019
1 parent 5402241 commit 8c8402d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/blockDetails/blockDetails.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ const blockLoadingSpinner = notFound =>
export const areAttributesTheSame = (oldAttributes, newAttributes) =>
oldAttributes.length === newAttributes.length &&
oldAttributes.every(
(old, i) => old.calculated.name === newAttributes[i].calculated.name
(old, i) =>
old.calculated.path &&
old.calculated.path.every(
(el, j) => el === newAttributes[i].calculated.path[j]
)
) &&
oldAttributes.every(
(old, i) => old.calculated.inGroup === newAttributes[i].calculated.inGroup
Expand Down Expand Up @@ -153,6 +157,7 @@ const displayAttributes = props => {
{props.methods.length > 0 ? (
<GroupDivider classes={props.classes} />
) : null}

{props.methods.map((method, i) => (
<div>
<MethodDetails
Expand Down Expand Up @@ -273,8 +278,9 @@ const mapStateToProps = (state, ownProps, memory) => {
a =>
a.calculated.isMethod &&
!(
block.orphans &&
block.orphans.some(orphan => orphan === a.calculated.name)
(a.raw.meta && a.raw.meta.tags.includes('method:hidden')) ||
(block.orphans &&
block.orphans.some(orphan => orphan === a.calculated.name))
)
);

Expand Down
4 changes: 3 additions & 1 deletion src/blockDetails/blockDetails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ describe('Block Details', () => {
inGroup: true,
isGroup: false,
isMethod: false,
path: ['block', 'test1'],
},
},
{
calculated: {
name: 'test2',
path: ['block', 'test2'],
},
},
];
Expand All @@ -222,7 +224,7 @@ describe('Block Details', () => {

newAttributes = buildAttributes(a => ({
...a,
calculated: { ...a.calculated, name: 'test1 new' },
calculated: { ...a.calculated, path: ['block', 'test1New'] },
}));
expect(areAttributesTheSame(oldAttributes, newAttributes)).toBeFalsy();

Expand Down

0 comments on commit 8c8402d

Please sign in to comment.