FIX: deleting a topic result not updated on screen

This commit is contained in:
Sam 2016-06-22 17:28:46 +10:00
parent 3701a8ada2
commit 6e4ff45e44
2 changed files with 7 additions and 3 deletions

View file

@ -758,7 +758,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
}, },
deleteTopic() { deleteTopic() {
this.unsubscribe();
this.get('content').destroy(Discourse.User.current()); this.get('content').destroy(Discourse.User.current());
}, },

View file

@ -109,8 +109,11 @@ class PostDestroyer
# When a user 'deletes' their own post. We just change the text. # When a user 'deletes' their own post. We just change the text.
def mark_for_deletion def mark_for_deletion
I18n.with_locale(SiteSetting.default_locale) do I18n.with_locale(SiteSetting.default_locale) do
# don't call revise from within transaction, high risk of deadlock
@post.revise(@user, { raw: I18n.t('js.post.deleted_by_author', count: SiteSetting.delete_removed_posts_after) }, force_new_version: true)
Post.transaction do Post.transaction do
@post.revise(@user, { raw: I18n.t('js.post.deleted_by_author', count: SiteSetting.delete_removed_posts_after) }, force_new_version: true)
@post.update_column(:user_deleted, true) @post.update_column(:user_deleted, true)
@post.update_flagged_posts_count @post.update_flagged_posts_count
@post.topic_links.each(&:destroy) @post.topic_links.each(&:destroy)
@ -122,9 +125,11 @@ class PostDestroyer
Post.transaction do Post.transaction do
@post.update_column(:user_deleted, false) @post.update_column(:user_deleted, false)
@post.skip_unique_check = true @post.skip_unique_check = true
@post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true)
@post.update_flagged_posts_count @post.update_flagged_posts_count
end end
# has internal transactions, if we nest then there are some very high risk deadlocks
@post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true)
end end
private private