How to show both states in a list

Hello. I am trying to load a list some items with photos and some without. What script can I use to show both in the list. In this episode there is a script in the date tab for this I suppose. Can you share this with us. Best, Marcos

You simply need to add “empty” list component and embed your main component inside that. Then change the embedded component state based on the value in Image prop. E.g. something like this:

if (typeof input !== ‘undefined’) {
if (input!=’’){
input=1; // if image exists then state is 1
} else {
input=0;
}
} else {
input=0;
}

return input;

1 Like

Thank you ver much. It worked

1 Like

I was able to do this but I am having an issue. I created the component with two states (two different backgrounds). I just want state 2 (input = 1) to be active when the value is the string ‘Modo Playback’ and for any other scenario it would be state 1 (input = 0). It works fine except when the document does not exist.

It is not that the field/value does not exist, but the document reference. The value “followMode” is supposed to be in the users collection with the same reference as the main collection, however it does not apply for all of the documents. So when the document is in the main collection but it is not in the users collection, the component does not appear in any state and I loose the background. This is my script:

And this is what I was describing:

In the top row there are documents that does not exist in the users collection so the background is gone, in the row below it is working just fine showing both states.

How should I modify the script to make it work?

not sure, but because it doesn’t exist yet is null
try if
(typeof input === undefined || typeof input === null)

|| means or …

I tried several combinations including the null option but it is not working. I added an additional white background so when the component is not there you see the other one. Now the result is like if everything is fine but the way to achieve it is not the appropriate one. But I got it working.

Thank you!

1 Like