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

Scripts with same id overwrite background #425

Closed
tobycheese opened this issue Sep 15, 2020 · 4 comments · Fixed by #471
Closed

Scripts with same id overwrite background #425

tobycheese opened this issue Sep 15, 2020 · 4 comments · Fixed by #471

Comments

@tobycheese
Copy link

tobycheese commented Sep 15, 2020

I have a bunch of tiles that call the same script, as follows:

           {
              position: [0, 0],
              type: TYPES.SCRIPT,
              id: 'script.sonos_wallpanel',
              bg: 'images/radiostations/radioparadise.png',
              variables: {source: 'radioparadise'},
           },
           {
              position: [1, 0],
              type: TYPES.SCRIPT,
              id: 'script.sonos_wallpanel',
              bg: 'images/radiostations/demoscene.png',
              variables: {source: 'demoscene'},
           },

Clicking these launch the script with different variable values, this works as expected. However, both tiles show the same background image radioparadise.png. When changing the id of the second tile, the background is then respected (demoscene.png is shown for the second tile).

@akloeckner
Copy link
Contributor

I believe, the background is cached in the state entity, and not in the tile item. Try changing that line to var obj = item;:

var obj = entity.attributes || entity;

Now, the question is why this is how it is. I'd suspect it is just a coincidence and most re-appearances of this piece of code could be changed in the way to use item instead of entity.

@tobycheese
Copy link
Author

tobycheese commented Sep 24, 2020

@akloeckner Yes, changing that line fixed the issue, thanks! Will this result in a fix eventually?

@rchl
Copy link
Collaborator

rchl commented Sep 24, 2020

Makes sense to change that IMO.

akloeckner added a commit to akloeckner/TileBoard that referenced this issue Oct 12, 2020
this change also makes this the default for a few other funtions, namely sliders.

fixes resoai#425

BREAKING CHANGE: The order of attrs and def is changed for a few sliders. This should not normally be a problem, because user would only use one of the possibilities. But... just to give note on that.
akloeckner added a commit to akloeckner/TileBoard that referenced this issue Oct 12, 2020
@rchl rchl closed this as completed in #471 Oct 12, 2020
rchl pushed a commit that referenced this issue Oct 12, 2020
@rchl
Copy link
Collaborator

rchl commented Oct 21, 2020

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants