Skip to content

Commit

Permalink
Merge pull request #98 from xmtp/np/reactions-bug
Browse files Browse the repository at this point in the history
Reaction Content Type Bug
  • Loading branch information
nplasterer authored Sep 6, 2023
2 parents 2076f51 + e91a3f5 commit b904ba0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 40 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:0.5.1"
implementation "org.xmtp:android:0.5.3"
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
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,15 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.5.0-alpha0):
- XMTP (0.5.1-alpha0):
- Connect-Swift
- GzipSwift
- web3.swift
- XMTPRust (= 0.3.1-beta0)
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- XMTP (= 0.5.0-alpha0)
- XMTP (= 0.5.1-alpha0)
- XMTPRust (0.3.1-beta0)
- Yoga (1.14.0)

Expand Down Expand Up @@ -680,8 +680,8 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 7773c4e96a99d7b8ab7cda0fc30a883732ff93b1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: 83467dcc466ce1280662e928f03688d6b735e80d
XMTPReactNative: 2b53a695526c89cb3430968c5aae1cac6815aa49
XMTP: 1f7a1daf482994871a920cb6fff4ee4ceeefae12
XMTPReactNative: 7dd97d8bd98a7fc8e70e3511c4f75de116450379
XMTPRust: 78f65f77b1454392980da244961777aee955652f
Yoga: 065f0b74dba4832d6e328238de46eb72c5de9556

Expand Down
78 changes: 44 additions & 34 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,46 +93,56 @@ test("createFromKeyBundle throws error for non string value", async () => {
});

test("can list batch messages", async () => {
try {
const bob = await XMTP.Client.createRandom({ env: "local" });
await delayToPropogate();
const alice = await XMTP.Client.createRandom({ env: "local" });
await delayToPropogate();
if (bob.address === alice.address) {
throw new Error("bob and alice should be different");
}
const bob = await XMTP.Client.createRandom({ env: "local" });
await delayToPropogate();
const alice = await XMTP.Client.createRandom({ env: "local" });
await delayToPropogate();
if (bob.address === alice.address) {
throw new Error("bob and alice should be different");
}

const bobConversation = await bob.conversations.newConversation(
alice.address
);
await delayToPropogate();
const bobConversation = await bob.conversations.newConversation(
alice.address
);
await delayToPropogate();

const aliceConversation = (await alice.conversations.list())[0];
if (!aliceConversation) {
throw new Error("aliceConversation should exist");
}
const aliceConversation = (await alice.conversations.list())[0];
if (!aliceConversation) {
throw new Error("aliceConversation should exist");
}

await bobConversation.send({ text: "Hello world" });
await delayToPropogate();
const messages: DecodedMessage[] = await alice.listBatchMessages([
{
contentTopic: bobConversation.topic,
} as Query,
{
contentTopic: aliceConversation.topic,
} as Query,
]);

if (messages.length < 1) {
throw Error("No message");
}
await bobConversation.send({ text: "Hello world" });
const bobMessages = await bobConversation.messages();
await bobConversation.send({
reaction: {
reference: bobMessages[0].id,
action: "added",
schema: "unicode",
content: "💖",
},
});

const firstMessage = messages?.[0];
const bobMessages2 = await bobConversation.messages();

return firstMessage.content.text === "Hello world";
} catch (e) {
return false;
await delayToPropogate();
const messages: DecodedMessage[] = await alice.listBatchMessages([
{
contentTopic: bobConversation.topic,
} as Query,
{
contentTopic: aliceConversation.topic,
} as Query,
]);

if (messages.length < 1) {
throw Error("No message");
}

if (messages[0].contentTypeId !== "xmtp.org/reaction:1.0") {
throw Error("Unexpected message content " + messages[0].content);
}

return true;
});

test("can paginate batch messages", async () => {
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Pod::Spec.new do |s|

s.source_files = "**/*.{h,m,swift}"
s.dependency "MessagePacker"
s.dependency "XMTP", "= 0.5.0-alpha0"
s.dependency "XMTP", "= 0.5.1-alpha0"
end

0 comments on commit b904ba0

Please sign in to comment.