diff --git a/api/server/publications.ts b/api/server/publications.ts index fc883f92a..b9be1aece 100644 --- a/api/server/publications.ts +++ b/api/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 }); });