mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fixes #143, reindex alias when removed
This commit is contained in:
parent
fac13fcf92
commit
f81b68bc71
2 changed files with 15 additions and 2 deletions
|
@ -256,9 +256,20 @@ defmodule Philomena.Tags do
|
||||||
end
|
end
|
||||||
|
|
||||||
def unalias_tag(%Tag{} = tag) do
|
def unalias_tag(%Tag{} = tag) do
|
||||||
|
former_alias = Repo.preload(tag, :aliased_tag).aliased_tag
|
||||||
|
|
||||||
tag
|
tag
|
||||||
|> Tag.unalias_changeset()
|
|> Tag.unalias_changeset()
|
||||||
|> Repo.update()
|
|> Repo.update()
|
||||||
|
|> case do
|
||||||
|
{:ok, _} = result ->
|
||||||
|
reindex_tag_images(former_alias)
|
||||||
|
|
||||||
|
result
|
||||||
|
|
||||||
|
result ->
|
||||||
|
result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp array_replace(queryable, column, old_value, new_value) do
|
defp array_replace(queryable, column, old_value, new_value) do
|
||||||
|
|
|
@ -29,10 +29,12 @@ defmodule PhilomenaWeb.Tag.AliasController do
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(conn, _params) do
|
def delete(conn, _params) do
|
||||||
|
spawn(fn ->
|
||||||
{:ok, _tag} = Tags.unalias_tag(conn.assigns.tag)
|
{:ok, _tag} = Tags.unalias_tag(conn.assigns.tag)
|
||||||
|
end)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, "Tag alias removed.")
|
|> put_flash(:info, "Tag dealias queued.")
|
||||||
|> redirect(to: Routes.tag_path(conn, :show, conn.assigns.tag))
|
|> redirect(to: Routes.tag_path(conn, :show, conn.assigns.tag))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue