BUGFIX: progress was 0 of 100 while a post is in transit
BUGFIX: highest_post_number could be incorrect BUGFIX: incorrect rendering of in-situ post (when its a reply)
This commit is contained in:
parent
7653262a07
commit
fb3e06bd64
|
@ -446,7 +446,6 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
title: this.get('title'),
|
title: this.get('title'),
|
||||||
category: this.get('categoryId'),
|
category: this.get('categoryId'),
|
||||||
topic_id: this.get('topic.id'),
|
topic_id: this.get('topic.id'),
|
||||||
reply_to_post_number: post ? post.get('post_number') : null,
|
|
||||||
imageSizes: opts.imageSizes,
|
imageSizes: opts.imageSizes,
|
||||||
cooked: this.getCookedHtml(),
|
cooked: this.getCookedHtml(),
|
||||||
reply_count: 0,
|
reply_count: 0,
|
||||||
|
@ -465,11 +464,22 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
auto_close_time: Discourse.Utilities.timestampFromAutocloseString(this.get('auto_close_time'))
|
auto_close_time: Discourse.Utilities.timestampFromAutocloseString(this.get('auto_close_time'))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(post) {
|
||||||
|
createdPost.setProperties({
|
||||||
|
reply_to_post_number: post.get('post_number'),
|
||||||
|
reply_to_user: {
|
||||||
|
username: post.get('username'),
|
||||||
|
uploaded_avatar_id: post.get('uploaded_avatar_id')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// If we're in a topic, we can append the post instantly.
|
// If we're in a topic, we can append the post instantly.
|
||||||
if (postStream) {
|
if (postStream) {
|
||||||
// If it's in reply to another post, increase the reply count
|
// If it's in reply to another post, increase the reply count
|
||||||
if (post) {
|
if (post) {
|
||||||
post.set('reply_count', (post.get('reply_count') || 0) + 1);
|
post.set('reply_count', (post.get('reply_count') || 0) + 1);
|
||||||
|
post.set('replies', []);
|
||||||
}
|
}
|
||||||
if (!postStream.stagePost(createdPost, currentUser)) {
|
if (!postStream.stagePost(createdPost, currentUser)) {
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,6 @@ Discourse.PostStream = Em.Object.extend({
|
||||||
|
|
||||||
// We can't stage two posts simultaneously
|
// We can't stage two posts simultaneously
|
||||||
if (this.get('stagingPost')) { return false; }
|
if (this.get('stagingPost')) { return false; }
|
||||||
|
|
||||||
this.set('stagingPost', true);
|
this.set('stagingPost', true);
|
||||||
|
|
||||||
var topic = this.get('topic');
|
var topic = this.get('topic');
|
||||||
|
@ -387,12 +386,14 @@ Discourse.PostStream = Em.Object.extend({
|
||||||
post.setProperties({
|
post.setProperties({
|
||||||
post_number: topic.get('highest_post_number'),
|
post_number: topic.get('highest_post_number'),
|
||||||
topic: topic,
|
topic: topic,
|
||||||
created_at: new Date()
|
created_at: new Date(),
|
||||||
|
id: -1
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we're at the end of the stream, add the post
|
// If we're at the end of the stream, add the post
|
||||||
if (this.get('loadedAllPosts')) {
|
if (this.get('loadedAllPosts')) {
|
||||||
this.appendPost(post);
|
this.appendPost(post);
|
||||||
|
this.get('stream').addObject(post.get('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -408,6 +409,15 @@ Discourse.PostStream = Em.Object.extend({
|
||||||
if (this.get('loadedAllPosts')) {
|
if (this.get('loadedAllPosts')) {
|
||||||
this.appendPost(post);
|
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'));
|
||||||
|
}
|
||||||
|
this.get('stream').removeObject(-1);
|
||||||
|
this.get('postIdentityMap').set(-1, null);
|
||||||
|
|
||||||
this.get('stream').addObject(post.get('id'));
|
this.get('stream').addObject(post.get('id'));
|
||||||
this.set('stagingPost', false);
|
this.set('stagingPost', false);
|
||||||
},
|
},
|
||||||
|
@ -420,16 +430,19 @@ Discourse.PostStream = Em.Object.extend({
|
||||||
@param {Discourse.Post} the post to undo from the stream
|
@param {Discourse.Post} the post to undo from the stream
|
||||||
**/
|
**/
|
||||||
undoPost: function(post) {
|
undoPost: function(post) {
|
||||||
|
this.get('stream').removeObject(-1);
|
||||||
this.posts.removeObject(post);
|
this.posts.removeObject(post);
|
||||||
|
this.get('postIdentityMap').set(-1, null);
|
||||||
|
|
||||||
var topic = this.get('topic');
|
var topic = this.get('topic');
|
||||||
|
|
||||||
this.set('stagingPost', false);
|
this.set('stagingPost', false);
|
||||||
|
|
||||||
topic.setProperties({
|
topic.setProperties({
|
||||||
highest_post_number: (topic.get('highest_post_number') || 0) - 1,
|
highest_post_number: (topic.get('highest_post_number') || 0) - 1,
|
||||||
posts_count: (topic.get('posts_count') || 0) - 1
|
posts_count: (topic.get('posts_count') || 0) - 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO unfudge reply count on parent post
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue