commit post not working properly when stage post was not called

caused issues editing posts that were committed by the composer
This commit is contained in:
Sam 2015-03-16 17:14:01 +11:00
parent 705e7105c8
commit 1d021d7019
1 changed files with 10 additions and 10 deletions

View File

@ -326,20 +326,20 @@ const PostStream = Ember.Object.extend({
// Commit the post we staged. Call this after a save succeeds. // Commit the post we staged. Call this after a save succeeds.
commitPost(post) { commitPost(post) {
// cleanup
if (this.get('topic.id') === post.get('topic_id')) {
if (this.get('loadedAllPosts')) { if (this.get('loadedAllPosts')) {
this.appendPost(post); this.appendPost(post);
} else {
// I guess we might as well keep the data
this.storePost(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'));
} }
this.get('stream').removeObject(-1); this.get('stream').removeObject(-1);
this.get('postIdentityMap').set(-1, null); 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); this.set('stagingPost', false);
}, },