mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
use correct preview endpoint, ensure changes were made before updating stat
This commit is contained in:
parent
eef6da6c78
commit
16843ec216
3 changed files with 9 additions and 5 deletions
|
@ -38,8 +38,6 @@ function commentReply(user, url, textarea, quote) {
|
||||||
function getPreview(body, anonymous, previewTab, isImage = false) {
|
function getPreview(body, anonymous, previewTab, isImage = false) {
|
||||||
let path = '/posts/preview';
|
let path = '/posts/preview';
|
||||||
|
|
||||||
if (isImage) path = '/images/preview';
|
|
||||||
|
|
||||||
fetchJson('POST', path, { body, anonymous })
|
fetchJson('POST', path, { body, anonymous })
|
||||||
.then(handleError)
|
.then(handleError)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|
|
@ -17,6 +17,7 @@ defmodule PhilomenaWeb.Image.SourceController do
|
||||||
def update(conn, %{"image" => image_params}) do
|
def update(conn, %{"image" => image_params}) do
|
||||||
attributes = conn.assigns.attributes
|
attributes = conn.assigns.attributes
|
||||||
image = conn.assigns.image
|
image = conn.assigns.image
|
||||||
|
old_source = image.source_url
|
||||||
|
|
||||||
case Images.update_source(image, attributes, image_params) do
|
case Images.update_source(image, attributes, image_params) do
|
||||||
{:ok, %{image: image}} ->
|
{:ok, %{image: image}} ->
|
||||||
|
@ -28,7 +29,9 @@ defmodule PhilomenaWeb.Image.SourceController do
|
||||||
|> where(image_id: ^image.id)
|
|> where(image_id: ^image.id)
|
||||||
|> Repo.aggregate(:count, :id)
|
|> Repo.aggregate(:count, :id)
|
||||||
|
|
||||||
|
if old_source != image.source_url do
|
||||||
UserStatistics.inc_stat(conn.assigns.current_user, :metadata_updates)
|
UserStatistics.inc_stat(conn.assigns.current_user, :metadata_updates)
|
||||||
|
end
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_view(PhilomenaWeb.ImageView)
|
|> put_view(PhilomenaWeb.ImageView)
|
||||||
|
|
|
@ -23,7 +23,10 @@ defmodule PhilomenaWeb.Image.TagController do
|
||||||
{:ok, %{image: {image, added_tags, removed_tags}}} ->
|
{:ok, %{image: {image, added_tags, removed_tags}}} ->
|
||||||
Images.reindex_image(image)
|
Images.reindex_image(image)
|
||||||
Tags.reindex_tags(added_tags ++ removed_tags)
|
Tags.reindex_tags(added_tags ++ removed_tags)
|
||||||
|
|
||||||
|
if Enum.any?(added_tags ++ removed_tags) do
|
||||||
UserStatistics.inc_stat(conn.assigns.current_user, :metadata_updates)
|
UserStatistics.inc_stat(conn.assigns.current_user, :metadata_updates)
|
||||||
|
end
|
||||||
|
|
||||||
tag_change_count =
|
tag_change_count =
|
||||||
TagChange
|
TagChange
|
||||||
|
|
Loading…
Reference in a new issue