Skip to content

Commit

Permalink
feat: support limit for load message into state
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Aug 17, 2022
1 parent ed1b43f commit c12b0ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/channel_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
* @param {string} messageId The id of the message, or 'latest' to indicate switching to the latest messages
* @param {string} parentMessageId The id of the parent message, if we want load a thread reply
*/
async loadMessageIntoState(messageId: string | 'latest', parentMessageId?: string) {
async loadMessageIntoState(messageId: string | 'latest', parentMessageId?: string, limit = 25) {
let messageSetIndex: number;
let switchedToMessageSet = false;
let loadedMessageThread = false;
Expand All @@ -686,10 +686,10 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
return;
}
if (!switchedToMessageSet) {
await this._channel.query({ messages: { id_around: messageIdToFind, limit: 25 } }, 'new');
await this._channel.query({ messages: { id_around: messageIdToFind, limit } }, 'new');
}
if (!loadedMessageThread && parentMessageId) {
await this._channel.getReplies(parentMessageId, { id_around: messageId, limit: 25 });
await this._channel.getReplies(parentMessageId, { id_around: messageId, limit });
}
messageSetIndex = this.findMessageSetIndex({ id: messageIdToFind });
if (messageSetIndex !== -1) {
Expand Down

0 comments on commit c12b0ff

Please sign in to comment.