Don't add duplicate posts to a discussion

This commit is contained in:
Toby Zerner 2015-06-15 08:59:57 +09:30
parent da461b1be7
commit cf7b6974bc
2 changed files with 6 additions and 2 deletions

View File

@ -88,7 +88,7 @@ class PostStream extends mixin(Component, evented) {
stream is not visible.
*/
pushPost(post) {
if (this.visibleEnd >= this.count() - 1) {
if (this.visibleEnd >= this.count() - 1 && this.posts.indexOf(post) === -1) {
this.posts.push(post);
this.visibleEnd++;
}

View File

@ -17,7 +17,11 @@ class Discussion extends Model {
}
if (newData.links && newData.links.addedPosts) {
[].push.apply(posts.linkage, newData.links.addedPosts.linkage);
newData.links.addedPosts.linkage.forEach(linkage => {
if (posts.linkage[posts.linkage.length - 1].id != linkage.id) {
posts.linkage.push(linkage);
}
});
}
}
}