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

Conversation list doesn't return all convos #343

Closed
nplasterer opened this issue Apr 3, 2024 · 0 comments · Fixed by #346
Closed

Conversation list doesn't return all convos #343

nplasterer opened this issue Apr 3, 2024 · 0 comments · Fixed by #346
Assignees
Labels
bug Something isn't working Partner Support

Comments

@nplasterer
Copy link
Contributor

For the convo list not returning the same count, I know what’s happening (and btw I was testing on iOS for that)
My code in RN is the following:

const importedConversations = await Promise.all(
   topicsData.map((data) => client.conversations.importTopicData(data))
);

This calls the following swift code
https://github.com/xmtp/xmtp-ios/blob/main/Sources/XMTPiOS/Conversations.swift#L165-L182
I have 1744 conversations, but if I log conversationsByTopic length at the end of this method, I see that
it logs a length of 1 many times in the beginning (sometimes ~10 times)
then it increases, so it does not end up at 1744 but sometimes 1735
So it means that conversationsByTopic is “reset” sometimes. And indeed, if I add a log here:
https://github.com/xmtp/xmtp-ios/blob/main/Sources/XMTPiOS/Conversations.swift#L60-L62
The init method is called like 10 times. So I think there is a race condition because of my Promise.all, the Conversations class is instantiated many times instead before being reused.
Hope that’s clear enough! Looks like I can fix it manually by calling first
await client.conversations.importTopicData(topicsData[0])
to init everything, then call my Promise.all, but that’s not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Partner Support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants