Skip to content

Commit 3057e70

Browse files
dotansimhadarkbasic
authored andcommitted
Step 10.1: Added counter for messages publication
1 parent b02b763 commit 3057e70

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

api/server/publications.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ Meteor.publish('users', function(): Mongo.Cursor<User> {
1515
});
1616
});
1717

18-
Meteor.publish('messages', function(chatId: string): Mongo.Cursor<Message> {
18+
Meteor.publish('messages', function(
19+
chatId: string,
20+
messagesBatchCounter: number): Mongo.Cursor<Message> {
1921
if (!this.userId || !chatId) {
2022
return;
2123
}
2224

2325
return Messages.collection.find({
2426
chatId
2527
}, {
26-
sort: { createdAt: -1 }
28+
sort: { createdAt: -1 },
29+
limit: 30 * messagesBatchCounter
2730
});
2831
});
2932

0 commit comments

Comments
 (0)