Permalink
Browse files

Step 10.1: Added counter for messages publication

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent b02b763 commit 3057e70472aa460b33082cbb0c2a8c271737ec00
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 3057e70

Please sign in to comment.