mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:04:53 +08:00
UX: Warn users if the post that's currently edited has changed. (#6498)
This commit is contained in:

committed by
Régis Hanol

parent
065bf0762c
commit
f60b10d090
@ -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]
|
||||
|
Reference in New Issue
Block a user