diff --git a/client/views/profile/profile.html b/client/views/profile/profile.html
index 9044f58..216f3b1 100644
--- a/client/views/profile/profile.html
+++ b/client/views/profile/profile.html
@@ -76,25 +76,25 @@
{{profile.name}}
-
-
+
-
-
+
{{stats.topicsCount}}
{{_ "topics"}}
-
-
+
{{activity.followers.length}}
{{_ "followers"}}
-
-
+
{{activity.followingUsers.length}}
{{_ "following"}}
diff --git a/client/views/profile/profile.js b/client/views/profile/profile.js
index beb2847..4a22f71 100644
--- a/client/views/profile/profile.js
+++ b/client/views/profile/profile.js
@@ -1,43 +1,42 @@
-Template.profileComments.created = function () {
- initInfiniteScroll.call(this, Comments.find({
- 'userId': this.data._id
+// profile comments ----------------------------------
+
+Template.profileComments.onCreated(function () {
+ initInfiniteScroll.call(this, Comments.find({ 'userId': this.data._id }, {
+ fields: { '_id': 1 }
}));
-};
-Template.profileComments.destroyed = function () {
+});
+Template.profileComments.onDestroyed(function () {
stopInfiniteScroll.call(this);
-};
-Template.profileTopics.created = function () {
- initInfiniteScroll.call(this, Topics.find({
- 'userId': this.data._id
+});
+
+// profile topics ------------------------------------
+
+Template.profileTopics.onCreated(function () {
+ initInfiniteScroll.call(this, Topics.find({ 'userId': this.data._id }, {
+ fields: { '_id': 1 }
}));
-};
-Template.profileTopics.destroyed = function () {
+});
+Template.profileTopics.onDestroyed(function () {
stopInfiniteScroll.call(this);
-};
+});
+
+// profile -------------------------------------------
Template.profile.helpers({
currentTab: function () {
- return Session.get('currentTab');
+ var controller = getCurrentController();
+ return controller.state.get('currentTab');
}
});
+// profile buttons -----------------------------------
+
Template.profileButtons.helpers({
ownProfile: function () {
- var userId = Meteor.userId();
- return userId && userId === this._id;
+ return Meteor.userId() === this._id;
}
});
-Template.profileHeader.helpers({
- canFollow: function () {
- return canFollow(Meteor.user(), this._id);
- },
- following: function () {
- return this.activity && this.activity.followers &&
- _.contains(this.activity.followers, Meteor.userId());
- }
-});
-
Template.profileButtons.events({
'click #js-settings': function (event, template) {
Router.go('settings', { '_id': this._id });
@@ -49,6 +48,18 @@ Template.profileButtons.events({
}
});
+// profile header ------------------------------------
+
+Template.profileHeader.helpers({
+ canFollow: function () {
+ return canFollow(Meteor.user(), this._id);
+ },
+ following: function () {
+ var followers = getProperty(this, 'activity.followers');
+ return followers && _.contains(followers, Meteor.userId());
+ }
+});
+
Template.profileHeader.events({
'click #js-follow': function (event, template) {
Meteor.call('newFollower', this._id, function (error) {
@@ -64,13 +75,23 @@ Template.profileHeader.events({
}
});
+// profile nav ---------------------------------------
+
+Template.profileNav.helpers({
+ activeClass: function (tab) {
+ var controller = getCurrentController();
+ return controller.state.get('currentTab') === tab && 'active';
+ }
+});
+
Template.profileNav.events({
'click .js-nav-button': function (event, template) {
- Session.set('currentTab', event.currentTarget.getAttribute('data-tab'));
+ var controller = getCurrentController();
+ controller.state.set('currentTab', event.currentTarget.getAttribute('data-tab'));
}
});
-// page tabs -----------------------------------------
+// profile tabs --------------------------------------
Template.profileTopics.helpers({
topics: function () {