From 1d021d701910013665b2baeb7cd353d300f72477 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 16 Mar 2015 17:14:01 +1100 Subject: [PATCH] commit post not working properly when stage post was not called caused issues editing posts that were committed by the composer --- .../discourse/models/post-stream.js.es6 | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/discourse/models/post-stream.js.es6 b/app/assets/javascripts/discourse/models/post-stream.js.es6 index 8fe2c7736f5..2d188aa073f 100644 --- a/app/assets/javascripts/discourse/models/post-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/post-stream.js.es6 @@ -326,20 +326,20 @@ const PostStream = Ember.Object.extend({ // Commit the post we staged. Call this after a save succeeds. commitPost(post) { - if (this.get('loadedAllPosts')) { - this.appendPost(post); - } - // Correct for a dangling deleted post, if needed - // compensating for message bus pumping in new posts while - // your post is in transit - if(this.get('topic.highest_post_number') < post.get('post_number')){ - this.set('topic.highest_post_number', post.get('post_number')); + + // cleanup + if (this.get('topic.id') === post.get('topic_id')) { + if (this.get('loadedAllPosts')) { + this.appendPost(post); + } else { + // I guess we might as well keep the data + this.storePost(post); + } } + this.get('stream').removeObject(-1); this.get('postIdentityMap').set(-1, null); - this.get('postIdentityMap').set(post.get('id'), post); - this.get('stream').addObject(post.get('id')); this.set('stagingPost', false); },