-
Notifications
You must be signed in to change notification settings - Fork 328
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
Add CarPlay Actions and general improvements #2517
Conversation
de9b5ff
to
2682987
Compare
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
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.
mostly for this i think the scene delegate needs a little bit of abstraction (making the providers an array, perhaps). otherwise i think this is definitely in the right direction.
4ee36a0
to
5b2745d
Compare
|
||
// Prevent unecessary update and UI glitch for non-touch screen CarPlay | ||
let entitiesIds = entitiesSorted.map(\.entityId).sorted() | ||
guard entitiesIdsCurrentlyInList != entitiesIds else { |
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.
does this ever match when pagination is required?
i think it may be easier to match the entities here in a dictionary to a CPListItem
, e.g.
// at a class level
var entityToListItem: [String: CPListItem]
// in this method
for entity in entities {
let listItem: CPListItem
if let existing = entityToListItem[entity.entityId] {
listItem = existing
} else {
listItem = CPListItem()
entityToListItem[entity.entityId] = listItem
}
// do updates / configure
}
i think you would need to move the "and change the items displayed" into the paginator to really invalidate/reset the template
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.
That is sort of what is happening already, the the list of entityIds change it means that some entity was added or removed, which means the paginated list needs an update, otherwise if the entityIds list is the same it means the state of an or multiple entities were updated, then those specific items are updated IF they are visible at that moment.
in CPListTemplate there is also not the concept of inserting a new item, so when we have a new entity we have to update the whole section
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 see the intent but I think pagination is making this "if" never work for cases where pagination happens at all.
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.
This check happens before everything is paginated, it's goal is just to prevent to recreate the list when the only thing that has changed was the state of entities. Let's say a new entity is added to your HA instance, then entitiesIds will have one more item and therefore different from entitiesIdsCurrentlyInList (previously set), which then will lead to the list being recreated.
Summary
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes