xmtp / xmtp-react-native

A package you can use to build with XMTP in a React Native or Expo app.
MIT License
41 stars 19 forks source link

Bug: `conversation.messages()` does not return everything #67

Closed nmalzieu closed 1 year ago

nmalzieu commented 1 year ago

Describe the bug

conversation.messages() seems to return max 100 messages => I think this is different than in the JS SDK which returns everything?

Expected behavior

No response

Steps to reproduce the bug

No response

Jonathansoufer commented 1 year ago

Isn't this due the fact of page size limits? If there is a limit of < 100, use that as the page size. Otherwise use 100 and stop if/when limit reached.

nmalzieu commented 1 year ago

@Jonathansoufer not sure I understand; in the web SDK, I think you just call conversation.messages() and get back everything, am I mistaken? Is the goal for the RN SDK to work like the web one?

Jonathansoufer commented 1 year ago

I'll try to replicate the behaviour on both SDKs and check what's going on then.

nplasterer commented 1 year ago

@Jonathansoufer I think the issue is a bit deeper than the react native SDK. I think the problem is that the iOS and Android SDKs just return the default from the protocol query method which is 100 messages. The SDKs have pagination but the client would have to do that to get all of the messages. In the JS SDK however we do that "pagination" for you in the SDK. So a call to messages will give you all the messages.

I think the fix here is actually going to be directly in the iOS and Android repos and changing client.query to client.listEnvelopes https://github.com/xmtp/xmtp-android/blob/main/library/src/main/java/org/xmtp/android/library/ConversationV2.kt#L61-L78 https://github.com/xmtp/xmtp-ios/blob/main/Sources/XMTP/ConversationV2.swift#L113-L126

I can open a fix in the Android repo if you'd like to take a stab at the iOS one. Let me know.

Jonathansoufer commented 1 year ago

Sure. He comes the PR for the iOS one (https://github.com/xmtp/xmtp-ios/pull/117)

nplasterer commented 1 year ago

Released in https://github.com/xmtp/xmtp-react-native/releases/tag/v1.6.1