hide favorites if empty

This commit is contained in:
Flummi 2022-01-03 05:14:19 +01:00
parent 80cdf94a59
commit e402efd7d3
2 changed files with 5 additions and 1 deletions

View File

@ -208,6 +208,8 @@ const flash = ({ type, msg }) => {
const favcontainer = document.querySelector('span#favs');
favcontainer.innerHTML = "";
favcontainer.hidden = !(favcontainer.hidden || res.favs.length > 0);
res.favs.forEach(f => {
const a = document.createElement('a');
a.href = `/user/${f.user}/favs`;
@ -244,6 +246,8 @@ const flash = ({ type, msg }) => {
addtagClick();
else if(e.key === "x")
deleteButtonEvent();
else if(e.key === "f")
toggleFavEvent();
});
}
})();

View File

@ -75,7 +75,7 @@
<a href="#" id="a_addtag">add tag</a>&nbsp;-&nbsp;<a href="#" id="a_toggle">toggle</a>
@endif
</span>
<span class="badge" id="favs">
<span class="badge" id="favs"@if(!item.favorites.length || !session) hidden@endif>
@if(item.favorites.length && session)
@each(item.favorites as fav)
<a href="/user/{{ fav.user.toLowerCase() }}/favs" tooltip="{{ fav.user }}" flow="down"><img src="@if(fav.avatar)/t/{{ fav.avatar }}@else/s/img/default@endif.png" style="height: 32px; width: 32px" /></a>