Skip to content

Commit

Permalink
Step 10.1: Added counter for messages publication
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 26, 2017
1 parent ed1e0a3 commit ab698ff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/publications.ts
Expand Up @@ -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
});
});

Expand Down

0 comments on commit ab698ff

Please sign in to comment.