UX: Warn users if the post that's currently edited has changed. (#6498)

This commit is contained in:
Bianca Nenciu
2018-10-17 16:35:32 +03:00
committed by Régis Hanol
parent 065bf0762c
commit f60b10d090
6 changed files with 55 additions and 6 deletions

View File

@ -200,7 +200,7 @@ class PostsController < ApplicationController
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
if !guardian.send("can_edit?", post) && post.user_id == current_user.id && post.edit_time_limit_expired?
return render json: { errors: [I18n.t('too_late_to_edit')] }, status: 422
return render_json_error(I18n.t('too_late_to_edit'))
end
guardian.ensure_can_edit!(post)
@ -210,6 +210,11 @@ class PostsController < ApplicationController
edit_reason: params[:post][:edit_reason]
}
raw_old = params[:post][:raw_old]
if raw_old.present? && raw_old != post.raw
return render_json_error(I18n.t('edit_conflict'), status: 409)
end
# to stay consistent with the create api, we allow for title & category changes here
if post.is_first_post?
changes[:title] = params[:title] if params[:title]