Permalink
Browse files

Step 10.1: Added counter for messages publication

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent c598a23 commit 6e9ab8818ea4a237394786a559b6e04a5495355c
Showing with 5 additions and 2 deletions.
  1. +5 −2 api/server/publications.ts
@@ -15,15 +15,18 @@ Meteor.publish('users', function(): Mongo.Cursor<User> {
});
});
Meteor.publish('messages', function(chatId: string): Mongo.Cursor<Message> {
Meteor.publish('messages', function(
chatId: string,
messagesBatchCounter: number): Mongo.Cursor<Message> {
if (!this.userId || !chatId) {
return;
}
return Messages.collection.find({
chatId
}, {
sort: { createdAt: -1 }
sort: { createdAt: -1 },
limit: 30 * messagesBatchCounter
});
});

0 comments on commit 6e9ab88

Please sign in to comment.