From ab698ffb5113cfc745737c2c305d4fcef858818a Mon Sep 17 00:00:00 2001 From: dotansimha Date: Tue, 24 Jan 2017 20:03:40 +0200 Subject: [PATCH] Step 10.1: Added counter for messages publication --- server/publications.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/publications.ts b/server/publications.ts index 9c3f137..e8b2511 100644 --- a/server/publications.ts +++ b/server/publications.ts @@ -15,7 +15,9 @@ Meteor.publish('users', function(): Mongo.Cursor { }); }); -Meteor.publish('messages', function(chatId: string): Mongo.Cursor { +Meteor.publish('messages', function( + chatId: string, + messagesBatchCounter: number): Mongo.Cursor { if (!this.userId || !chatId) { return; } @@ -23,7 +25,8 @@ Meteor.publish('messages', function(chatId: string): Mongo.Cursor { return Messages.collection.find({ chatId }, { - sort: { createdAt: -1 } + sort: { createdAt: -1 }, + limit: 30 * messagesBatchCounter }); });