Skip to content

Commit

Permalink
Merge pull request #134 from xmtp/np/fix-android-streaming
Browse files Browse the repository at this point in the history
Fix: Android Stream All Messages
  • Loading branch information
nplasterer authored Sep 30, 2023
2 parents 7eecc49 + 2467023 commit 7266085
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/androidTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ jobs:
- name: Install React Native CLI
run: npm i -g react-native-cli --force

# Workaround for https://github.com/actions/runner-images/issues/8104
- name: Fix Qemu Error
run: |
brew remove --ignore-dependencies qemu
curl -o ./qemu.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/f88e30b3a23ef3735580f9b05535ce5a0a03c9e3/Formula/qemu.rb
brew install ./qemu.rb
- name: Install docker
run: brew install docker docker-compose

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:0.6.4"
implementation "org.xmtp:android:0.6.5"
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.facebook.react:react-native:0.71.3'
implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1"
Expand Down
54 changes: 54 additions & 0 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,57 @@ test("can send read receipts", async () => {
return true;
});

test("can stream all messages", async () => {
const bo = await XMTP.Client.createRandom({ env: "local" });
await delayToPropogate();
const alix = await XMTP.Client.createRandom({ env: "local" });
await delayToPropogate();

// Record message stream across all conversations
const allMessages: DecodedMessage[] = [];
await alix.conversations.streamAllMessages(async (message) => {
allMessages.push(message);
});

// Start Bob starts a new conversation.
const boConvo = await bo.conversations.newConversation(alix.address);
await delayToPropogate();

for (let i = 0; i < 5; i++) {
await boConvo.send({ text: `Message ${i}` });
await delayToPropogate();
}
if (allMessages.length !== 5) {
throw Error("Unexpected all messages count " + allMessages.length);
}

// Starts a new conversation.
const caro = await XMTP.Client.createRandom({ env: "local" });
const caroConvo = await caro.conversations.newConversation(alix.address);
await delayToPropogate();
for (let i = 0; i < 5; i++) {
await caroConvo.send({ text: `Message ${i}` });
await delayToPropogate();
}
if (allMessages.length !== 10) {
throw Error("Unexpected all messages count " + allMessages.length);
}

alix.conversations.cancelStreamAllMessages();

await alix.conversations.streamAllMessages(async (message) => {
allMessages.push(message);
});

for (let i = 0; i < 5; i++) {
await boConvo.send({ text: `Message ${i}` });
await delayToPropogate();
}
if (allMessages.length <= 10) {
throw Error("Unexpected all messages count " + allMessages.length);
}


return true;
});

0 comments on commit 7266085

Please sign in to comment.