fixes #143, reindex alias when removed

This commit is contained in:
byte[] 2020-06-16 13:10:52 -04:00
parent fac13fcf92
commit f81b68bc71
2 changed files with 15 additions and 2 deletions

View file

@ -256,9 +256,20 @@ defmodule Philomena.Tags do
end
def unalias_tag(%Tag{} = tag) do
former_alias = Repo.preload(tag, :aliased_tag).aliased_tag
tag
|> Tag.unalias_changeset()
|> Repo.update()
|> case do
{:ok, _} = result ->
reindex_tag_images(former_alias)
result
result ->
result
end
end
defp array_replace(queryable, column, old_value, new_value) do

View file

@ -29,10 +29,12 @@ defmodule PhilomenaWeb.Tag.AliasController do
end
def delete(conn, _params) do
{:ok, _tag} = Tags.unalias_tag(conn.assigns.tag)
spawn(fn ->
{:ok, _tag} = Tags.unalias_tag(conn.assigns.tag)
end)
conn
|> put_flash(:info, "Tag alias removed.")
|> put_flash(:info, "Tag dealias queued.")
|> redirect(to: Routes.tag_path(conn, :show, conn.assigns.tag))
end
end