Gracefully handle discussions with no posts

Although this should never happen
This commit is contained in:
Toby Zerner
2015-06-23 10:30:06 +09:30
parent 45ba693154
commit 3a7efe202e
4 changed files with 9 additions and 9 deletions

View File

@ -58,7 +58,7 @@ Discussion.prototype.canRename = Model.prop('canRename');
Discussion.prototype.canDelete = Model.prop('canDelete');
Discussion.prototype.commentsCount = Model.prop('commentsCount');
Discussion.prototype.repliesCount = computed('commentsCount', commentsCount => commentsCount - 1);
Discussion.prototype.repliesCount = computed('commentsCount', commentsCount => Math.max(0, commentsCount - 1));
Discussion.prototype.posts = Model.many('posts');
Discussion.prototype.postIds = function() { return this.data().links.posts.linkage.map((link) => link.id); };