From 22d2b28a6eea6abe9d661fcf2a79fe7cc3aaeff4 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 14 Feb 2024 14:07:12 -0800 Subject: [PATCH] fix the synchronous issue --- example/ios/Podfile.lock | 8 ++++---- example/src/tests.ts | 9 +++++---- ios/XMTPModule.swift | 3 +-- ios/XMTPReactNative.podspec | 2 +- src/lib/Group.ts | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index cfdb0197c..45b159e13 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -442,7 +442,7 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.8.4): + - XMTP (0.8.5): - Connect-Swift (= 0.3.0) - GzipSwift - LibXMTP (= 0.4.1-beta3) @@ -451,7 +451,7 @@ PODS: - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.8.4) + - XMTP (= 0.8.5) - Yoga (1.14.0) DEPENDENCIES: @@ -744,8 +744,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: b02b5075dcf60c9f5f403000b3b0c202a11b6ae1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: fe278c4c9e2d71b607c1816d16a37a1f8fef83f1 - XMTPReactNative: b5b61eb97c27848d26f87043cb3845059968b5e5 + XMTP: 1957e318059e8723bc1e76b1723c1eeb98e7760b + XMTPReactNative: 048504b17f0a7f9380b48ddeda6bfb15f7a5d799 Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 diff --git a/example/src/tests.ts b/example/src/tests.ts index dc2c4b37c..82b737d8d 100644 --- a/example/src/tests.ts +++ b/example/src/tests.ts @@ -227,23 +227,24 @@ test('can message in a group', async () => { ) { throw new Error('missing address') } + await bobClient.conversations.syncGroups() // Alice can send messages - aliceGroup.send('hello, world') - aliceGroup.send('gm') + await aliceGroup.send('hello, world') + await aliceGroup.send('gm') // Bob's num groups == 1 - await bobClient.conversations.syncGroups() const bobGroups = await bobClient.conversations.listGroups() if (bobGroups.length !== 1) { throw new Error( 'num groups for bob should be 1, but it is' + bobGroups.length ) } - + delayToPropogate() // Bob can read messages from Alice await bobGroups[0].sync() const bobMessages: DecodedMessage[] = await bobGroups[0].messages() + if (bobMessages.length !== 2) { throw new Error( 'num messages for bob should be 2, but it is' + bobMessages.length diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 4b1409b01..cdb0874e1 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -426,11 +426,10 @@ public class XMTPModule: Module { } let sending = try ContentJson.fromJson(contentJson) - try await group.send( + return try await group.send( content: sending.content, options: SendOptions(contentType: sending.type) ) - return group.id.toHex } AsyncFunction("prepareMessage") { ( diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index 5aa2d055a..066da9acd 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency 'secp256k1.swift' s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.8.4" + s.dependency "XMTP", "= 0.8.5" end diff --git a/src/lib/Group.ts b/src/lib/Group.ts index 842cdb2f2..c2a012f08 100644 --- a/src/lib/Group.ts +++ b/src/lib/Group.ts @@ -63,7 +63,7 @@ export class Group< content ) } catch (e) { - console.info('ERROR in send()', e) + console.info('ERROR in send()', e.message) throw e } }