philomena/lib/philomena_web/templates/image/subscription/_subscription.html.heex

32 lines
767 B
Text
Raw Permalink Normal View History

2024-05-04 23:09:44 +02:00
<% watch_path = ~p"/images/#{@image}/subscription"
2024-05-04 23:09:20 +02:00
2024-05-04 23:09:44 +02:00
watch_class =
if @watching do
"hidden"
else
""
end
2024-05-04 23:09:20 +02:00
2024-05-04 23:09:44 +02:00
unwatch_path = ~p"/images/#{@image}/subscription"
2024-05-04 23:09:20 +02:00
2024-05-04 23:09:44 +02:00
unwatch_class =
if @watching do
""
else
"hidden"
end %>
2024-05-04 23:09:20 +02:00
<%= if @conn.assigns.current_user do %>
<span class="js-subscription-target">
<a class={"js-subscription-link #{watch_class}"} data-method="post" data-remote="true" href={watch_path}>
2024-05-04 23:09:44 +02:00
<i class="fa fa-bell"></i> Subscribe
2024-05-04 23:09:20 +02:00
</a>
<a class={"js-subscription-link #{unwatch_class}"} data-method="delete" data-remote="true" href={unwatch_path}>
2024-05-04 23:09:44 +02:00
<i class="fa fa-bell-slash"></i> Unsubscribe
2024-05-04 23:09:20 +02:00
</a>
</span>
<% else %>
<a href={~p"/sessions/new"}>
2024-05-04 23:09:44 +02:00
<i class="fa fa-bell"></i> Subscribe
2024-05-04 23:09:20 +02:00
</a>
<% end %>