-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Device page: sort related automations, scenes, scripts #24742
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
base: dev
Are you sure you want to change the base?
Conversation
#23740 is related. |
const entry = this._entityReg.find( | ||
(e) => e.entity_id === script | ||
(e) => e.entity_id === (script as any) |
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.
script is an stateObj
right? So this should be?
(e) => e.entity_id === (script as any) | |
(e) => e.entity_id === script.entity_id |
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.
My bad! Fixed.
entityState.attributes.id | ||
? `/config/automation/edit/${encodeURIComponent(entityState.attributes.id)}` | ||
: undefined | ||
${this._toEntities(this._related.automation).map( |
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.
We should wrap this in memoized, so we don't do the sorting and filtering on every render.
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.
I would make this 1 memoized function, that returns all the sorted and filtered entities:
private _getRelated_ = memoizeOne((this._related) => {entity: [], automation: [], ... });
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.
Refactored to memoize. Hope I did it right..
But the entity
part is not included in the same memoize, it is in a different one (which was already present).
entities | ||
.map((entity) => ({ | ||
...entity, | ||
stateName: this._computeEntityName(entity), |
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.
_computeEntityName
takes a EntityRegistryEntry
, you are passing a state object to it. Please add proper typing so these things pop up automatically.
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.
Changed the code, please review.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Breaking change
Proposed change
Before / after:
Notes:
ha-config-device-page
class has same_toEntities()
(entity_ids -> objects) method asha-related-items
. Probably it should be made as a common function then.ha-tooltip
for related automations. Currently it is not present for scripts but is for automations & scenes.href
for related entities between "automation & scenes" AND scripts. Looks like these blocks were written differently.Trying to fix it.... Changed the comparison to
e.entity_id === script as any
.Suggest to some Dev person (or to myself) to sort out these mentioned differences between blocks for related entities.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: