mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +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
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue