Hello,
i am working on a like / unlike system and i have problems in Volt.
i can delete and insert data in controler, but when i want to display the data, i get it multiple times or if the data are empty i get nothing.
So, If loggedUserId == likes.clickedId i want to display <i class="fa fa-heart-o" aria-hidden="true"></i>, but it displays <i class="fa fa-heart" aria-hidden="true"></i>.
If loggedUserId == likes.clickedId is empty I want to display <i class="fa fa-heart" aria-hidden="true"></i>, but it displays nothing.
{% for likes in user.likes %}
{% if loggedUserId == likes.clickedId %}
{{ tag_html("a", ["href":"likes?usersId=" ~ user.id ~ "&unlike=unlike", "role":"tooltip", "data-toggle":"tooltip","data-placement":"top", "title":"Like me","class": "email-ic unlike"]) }}
<i class="fa fa-heart-o" aria-hidden="true"></i>
<span style="font-size: 10px">
{% for sumLikes in totalLikes %}
{% if user.id == sumLikes.usersId %}
{{ sumLikes.totalLikesDB }}
{% endif %}
{% endfor %}
</span>
{{ tag_html_close("a") }}
{% else %}
{{ tag_html("a", ["href":"likes?usersId=" ~ user.id ~ "&like=like", "role":"tooltip", "data-toggle":"tooltip","data-placement":"top", "title":"Like me","class": "email-ic unlike"]) }}
<i class="fa fa-heart" aria-hidden="true"></i>
<span style="font-size: 10px">
{% for sumLikes in totalLikes %}
{% if user.id == sumLikes.usersId %}
{{ sumLikes.totalLikesDB }}
{% endif %}
{% endfor %}
</span>
{{ tag_html_close("a") }}
{% endif %}
{% endfor %}
Best wishes and thank you in advance