From f82cee92425b94e68a8ebb3e4dab62a093737479 Mon Sep 17 00:00:00 2001 From: erasaur Date: Fri, 1 May 2015 23:13:54 -0700 Subject: [PATCH] Handle commentReply subs at the template level #6, show loader when subscriptions are loading #3 --- client/views/comments/replies.html | 20 ++++++++++++-------- client/views/comments/replies.js | 10 +++++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/client/views/comments/replies.html b/client/views/comments/replies.html index ea179a0..b31b9aa 100644 --- a/client/views/comments/replies.html +++ b/client/views/comments/replies.html @@ -1,15 +1,19 @@ diff --git a/client/views/comments/replies.js b/client/views/comments/replies.js index dc27356..befe67a 100644 --- a/client/views/comments/replies.js +++ b/client/views/comments/replies.js @@ -1,4 +1,8 @@ -Template.replies.rendered = function () { +Template.replies.onCreated(function () { + this.subscribe('commentReplies', this.data.id); +}); + +Template.replies.onRendered(function () { var container = this.firstNode; container._uihooks = { insertElement: function (node, next) { @@ -14,11 +18,11 @@ Template.replies.rendered = function () { } } } -}; +}); Template.replies.helpers({ hasReplies: function () { - var comment = Comments.findOne(this.id); + var comment = Comments.findOne(this.id, { fields: { 'replies': 1 } }); return comment && comment.replies.length; }, replies: function () {