mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
fix lingering galleries bugs
This commit is contained in:
parent
ea3d40375f
commit
391c754a42
3 changed files with 12 additions and 11 deletions
|
@ -241,7 +241,7 @@ nav {
|
|||
width: 100%;
|
||||
|
||||
/* Do not use a descendant selector here as it affects dropdowns */
|
||||
> a {
|
||||
> a, span {
|
||||
text-align: center;
|
||||
flex: 1 1 auto;
|
||||
padding: 0 1vw; /* Having smaller padding makes it harder to click the right link on small mobile screens */
|
||||
|
|
|
@ -155,16 +155,20 @@ defmodule Philomena.Galleries do
|
|||
def remove_image_from_gallery(gallery, image) do
|
||||
Multi.new()
|
||||
|> Multi.run(:interaction, fn repo, %{} ->
|
||||
%Interaction{gallery_id: gallery.id, image_id: image.id}
|
||||
|> repo.delete()
|
||||
{count, nil} =
|
||||
Interaction
|
||||
|> where(gallery_id: ^gallery.id, image_id: ^image.id)
|
||||
|> repo.delete_all()
|
||||
|
||||
{:ok, count}
|
||||
end)
|
||||
|> Multi.run(:gallery, fn repo, %{} ->
|
||||
|> Multi.run(:gallery, fn repo, %{interaction: interaction_count} ->
|
||||
now = DateTime.utc_now()
|
||||
|
||||
{count, nil} =
|
||||
Gallery
|
||||
|> where(id: ^gallery.id)
|
||||
|> repo.update_all(inc: [image_count: -1], set: [updated_at: now])
|
||||
|> repo.update_all(inc: [image_count: -interaction_count], set: [updated_at: now])
|
||||
|
||||
{:ok, count}
|
||||
end)
|
||||
|
|
|
@ -9,15 +9,12 @@ elixir:
|
|||
span#js-subscription-target
|
||||
a.js-subscription-link href=watch_path class=watch_class data-remote="true" data-method="post"
|
||||
i.fa.fa-bell>
|
||||
span.hide-mobile
|
||||
' Subscribe
|
||||
' Subscribe
|
||||
|
||||
a.js-subscription-link href=unwatch_path class=unwatch_class data-remote="true" data-method="delete"
|
||||
i.fa.fa-bell-slash>
|
||||
span.hide-mobile
|
||||
' Unsubscribe
|
||||
' Unsubscribe
|
||||
- else
|
||||
a href=Routes.pow_session_path(@conn, :new)
|
||||
i.fa.fa-bell>
|
||||
span.hide-mobile
|
||||
' Subscribe
|
||||
' Subscribe
|
||||
|
|
Loading…
Reference in a new issue