Commit 948c3d97 authored by Manuel Gauto's avatar Manuel Gauto
Browse files

All Channels are published. Clients now subscribe to ChannelMemberships....

All Channels are published. Clients now subscribe to ChannelMemberships. Channels now rendered at home
parent 064a7df0
......@@ -4,7 +4,7 @@
<div class="large-2 columns">
<ul class="side-nav" role="navigation" title="Channel List">
{{#each channels}}
<li role="menuitem"><a class="chanSelect" data-chanId="{{_id}}" href="#">{{channelName channel._id}}</a></li>
<li role="menuitem"><a class="chanSelect" data-chanId="{{_id}}" href="#">{{channelName _id}}</a></li>
{{/each}}
</ul>
</div>
......@@ -13,7 +13,8 @@
<div class="large-7 columns">
<table>
{{#each messages}}
<td>{{username senderId}}<>
<td>{{username senderId}}</td>
<td>{{content}}</td>
{{/each}}
</table>
</div>
......
......@@ -56,17 +56,18 @@ Messages.attachSchema(Schemas.Message);
if(Meteor.isServer) {
Meteor.publish('channels', function() {
return Channels.find();
//Get UserId
var curUserId = this.userId;
//var curUserId = this.userId;
//Get the ChannelMemberships for the user
var channelAsso = ChannelMemberships.find({userId: curUserId}).fetch();
//var channelAsso = ChannelMemberships.find({userId: curUserId}).fetch();
for(var i = 0; i < channelAsso.length; i++) {
var channelMembership = channelAssoc[i];
var channelToAdd = Channels.findOne(channelMembership.channelId);
this.added('channels', channelToAdd._id, channelToAdd);
}
this.ready();
//for(var i = 0; i < channelAsso.length; i++) {
// var channelMembership = channelAssoc[i];
// var channelToAdd = Channels.findOne(channelMembership.channelId);
// this.added('channels', channelToAdd._id, channelToAdd);
//}
//this.ready();
});
Meteor.publish('messages', function() {
//Get UserId
......@@ -158,4 +159,5 @@ if(Meteor.isServer) {
if(Meteor.isClient) {
Meteor.subscribe('channels');
Meteor.subscribe('messages');
Meteor.subscribe('channelMembership');
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment