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

Sort related automations, scripts and scenes on device info page #23740

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

jpbede
Copy link
Member

@jpbede jpbede commented Jan 14, 2025

Proposed change

Sort the related automations, scripts and scenes on the device info page as we already do in the more-info dialog.

Instead of copying the code for the sorting, I moved it to a central place (I hope the right one, otherwise please suggest the right one 🙂) and adjusted the related items in the more-info dialog to use it.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@jpbede jpbede changed the title Sort related on device info page Sort related automations, scripts and scenes on device info page Jan 14, 2025
@bramkragten bramkragten self-assigned this Jan 28, 2025
Comment on lines +76 to 78
private _toEntities = memoizeOne((entityIds: string[]) =>
entityIds.map((entityId) => this.hass.states[entityId])
);
Copy link
Contributor

Choose a reason for hiding this comment

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

This change will defeat the purpose of MemoizeOne here. You can read about MemoizeOne here: https://www.npmjs.com/package/memoize-one#usage

Previously, we had individual MemoizeOne on entities, groups, automations, scripts, ...
So, if the related scripts don't change, memoize will return the cache result fast upon each rendering.

With these changes, only one MemoizeOne remains and since we fetch related entities, groups, automations, scripts and so on in sequence, it will never be able to return the cache.

@home-assistant
Copy link

home-assistant bot commented Mar 6, 2025

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft March 6, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Device info page - automations, scripts, scenes aren't sorted alphabetically
4 participants