Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: layer with shared encoding ignore repeater #9246

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ChiaLingWeng
Copy link
Contributor

close #8734

I noticed that the main reason for the spec failed to replace repeat is due to there are some problem when handling the shared layer encoding, the params.repeater will be read when running mapUnit at the first time, but since in shared layer spec, the encoding will not be at the same layer as the repeater, and the repeater will not be record since mapUnitWithParentEncodingOrProjection will return config only, and the repeat is thus cannot be replaced.

I am not familiar with typescript so using some redundant code, I think this can be clean up and be more concised.

@ChiaLingWeng ChiaLingWeng requested a review from a team as a code owner February 1, 2024 17:00
},
{config}
);
if (this.isEmpty(encoding) && !this.isEmpty(params.repeater)) {
Copy link
Member

@domoritz domoritz Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this check to the second argument of the map unit method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, simplify and updated!

@@ -212,6 +211,13 @@ export class CoreNormalizer extends SpecMapper<NormalizerParams, FacetedUnitSpec

return super.mapFacet(spec, params);
}
//
private isEmpty(obj: any) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a helper function outside of this class, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, move this outside the class

@@ -398,3 +405,10 @@ function mergeProjection<ES extends ExprRef | SignalRef>(opt: {
}
return projection ?? parentProjection;
}

function emptyFlag(obj: any) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking this should be it utils. We already have isEmpty there so you could use that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested code above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know that!

return this.mapUnit(
{
...spec,
...(mergedProjection ? {projection: mergedProjection} : {}),
...(mergedEncoding ? {encoding: mergedEncoding} : {})
},
{config}
emptyFlag(encoding) && !emptyFlag(params.repeater)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
emptyFlag(encoding) && !emptyFlag(params.repeater)
isEmpty(encoding ?? {}) && ! isEmpty(params.repeater ?? {})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repeat spec with shared encoding does not replace repeat
2 participants