Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support limit for load message into state #1031

Merged
merged 1 commit into from
Aug 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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