fraction/fraction

View on GitHub
app/packages/fraction-routes/lib/routes/comments.next.js

Summary

Maintainability
A
40 mins
Test Coverage
'use strict';

Routes.comments = {
  name: 'comments',
  controller: Routes.Controllers.page,
  path: '/comments/:id',
  template: 'listComments',
  waitOn: function () {
    if (Session.equals('sortType', undefined)) {
        Routes.hot.waitOn();
    }
    return Meteor.subscribe('comments', this.params.id);
  },
  onAfterAction: function () {
    Session.set('comments', Posts.find({
      _id: this.params.id
    }, {
      reactive: false
    }).fetch());

    Session.set('showComments', true);
    Session.set('currentView', 'Comments');
    Session.set('currentPost', this.params.id);

    if (Session.equals('sortType', undefined)) {
      Routes.hot.onAfterAction();
    }
  }
};