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

Remove deprecated xmtp-js pagination code #545

Merged
merged 1 commit into from
Aug 22, 2023
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
21 changes: 0 additions & 21 deletions docs/build/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,27 +251,6 @@ for (const conversation of await xmtp.conversations.list()) {
If a conversation has a lot of messages, it's more performant to retrieve and process the messages page by page instead of handling all of the messages at once.

<Tabs groupId="sdk-langs">
<TabItem value="js" label="JavaScript" attributes={{className: "js_tab"}}>

Call `conversation.messagesPaginated()`, which will return an [AsyncGenerator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator) yielding one page of results at a time. `conversation.messages()` uses this under the hood internally to gather all messages.

```ts
const conversation = await xmtp.conversations.newConversation(
"0x3F11b27F323b62B159D2642964fa27C46C841897",
);

for await (const page of conversation.messagesPaginated({ pageSize: 25 })) {
for (const msg of page) {
// Breaking from the outer loop will stop the client from requesting any further pages
if (msg.content === "gm") {
return;
}
console.log(msg.content);
}
}
```

</TabItem>
<TabItem value="swift" label="Swift" attributes={{className: "swift_tab"}}>

Call `conversation.messages(limit: Int, before: Date)`, which will return the specified number of messages sent before that time.
Expand Down
Loading