Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Step 10.1: Added counter for messages publication
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 13, 2017
1 parent 1cd545f commit c3fee52
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 c3fee52

Please sign in to comment.