Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

fix: don't cache icon background #471

Merged
merged 4 commits into from
Oct 12, 2020
Merged

Conversation

akloeckner
Copy link
Contributor

fixes #425

scripts/controllers/main.js Outdated Show resolved Hide resolved
@rchl
Copy link
Collaborator

rchl commented Oct 12, 2020

Actually, I've just realized some potential issues with it. The background of the entity can change dynamically - for example, media player tiles' background should change on every song. I think this will break that.

@akloeckner
Copy link
Contributor Author

That's true. But it was broken before then already. Nice thing about the new implementation with cacheInItem is that we can simply remove that function call and be good... ;-)

Shall we? I don't know the inner workings of AngularJS well enough.

We could also add a dummy cache, which is updated constantly, but will prevent any watchers from executing. Or do we need the watchers to execute in order to update the background? Seems a bit overdone to me, anyways.

@rchl
Copy link
Collaborator

rchl commented Oct 12, 2020

It wasn't broken before. Probably because the entity was recreated every time there was an update so caching didn't really do much in practice.

If we return a new object every time this function is called then angular will notify all watchers, even if the values didn't really change. And that means that the DOM style property will be updated every time. I guess that was happening before anyway and the browser will actually optimize it so that nothing really happens. So while ideally we would not notify listeners, I'm fine with just returning a new object every time.

@rchl rchl changed the title fix: caching of icon background fix: don't cache icon background Oct 12, 2020
@rchl rchl merged commit f9ea1ef into resoai:master Oct 12, 2020
@rchl rchl added the hacktoberfest-accepted Accept for Hacktoberfest label Oct 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hacktoberfest-accepted Accept for Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scripts with same id overwrite background
2 participants