-
Notifications
You must be signed in to change notification settings - Fork 246
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
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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]
?
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
.
Fixes #698 (comment)