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: Use a proper config in renderState() #1217

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

ildar170975
Copy link
Collaborator

Copy link
Collaborator

@akloeckner akloeckner left a comment

Choose a reason for hiding this comment

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

Thanks! I had thought about starting this already myself, but then delayed it, because I wasn't sure about the logics of the changes. I left some recommendations...

src/main.js Outdated
@@ -291,14 +291,16 @@ class MiniGraphCard extends LitElement {
const state = this.getEntityState(id);
// use tooltip data for main state element, if tooltip is active
const { entity: tooltipEntity, value: tooltipValue } = this.tooltip;
const value = isPrimary && tooltipEntity !== undefined ? tooltipValue : state;
const entity = isPrimary && tooltipEntity !== undefined ? tooltipEntity : id;
const condition = isPrimary && tooltipEntity !== undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we give a speaking name to the condition? E.g. isTooltip?

src/main.js Outdated
const condition = isPrimary && tooltipEntity !== undefined;
const value = condition ? tooltipValue : state;
const entity = condition ? tooltipEntity : id;
const entity_config = condition ? this.config.entities[entity] : entityConfig;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't entityConfig = this.config.entities[id]?

Suggested change
const entity_config = condition ? this.config.entities[entity] : entityConfig;
const entity_config = this.config.entities[entity];

If we change this, we can possibly also get rid of the additional function argument? Bear in mind that it's used a few lines before already...

And for consistent style, I would then call the constant camelcased entityConfig.

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