diff --git a/Package.resolved b/Package.resolved index c0ca7c96..ed272fb7 100644 --- a/Package.resolved +++ b/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/libxmtp-swift.git", "state" : { - "revision" : "d6670069b6f7ae52415c691dbca4c37fbdaf87b4", - "version" : "3.0.12" + "revision" : "203fd6d67bb72e3114b273ce9bbddd6fc747d583", + "version" : "3.0.13" } }, { diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index 1c1b5d4c..96155a0b 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -450,18 +450,18 @@ public final class Client { } } - public func findConversation(conversationId: String) throws -> Conversation? + public func findConversation(conversationId: String) async throws -> Conversation? { do { let conversation = try ffiClient.conversation( conversationId: conversationId.hexToData) - return try conversation.toConversation(client: self) + return try await conversation.toConversation(client: self) } catch { return nil } } - public func findConversationByTopic(topic: String) throws -> Conversation? { + public func findConversationByTopic(topic: String) async throws -> Conversation? { do { let regexPattern = #"/xmtp/mls/1/g-(.*?)/proto"# if let regex = try? NSRegularExpression(pattern: regexPattern) { @@ -473,7 +473,7 @@ public final class Client { with: match.range(at: 1)) let conversation = try ffiClient.conversation( conversationId: conversationId.hexToData) - return try conversation.toConversation(client: self) + return try await conversation.toConversation(client: self) } } } catch { diff --git a/Sources/XMTPiOS/Conversations.swift b/Sources/XMTPiOS/Conversations.swift index 2cca261b..ec3d4e43 100644 --- a/Sources/XMTPiOS/Conversations.swift +++ b/Sources/XMTPiOS/Conversations.swift @@ -162,15 +162,19 @@ public actor Conversations { if let limit { options.limit = Int64(limit) } - let conversations = try await ffiConversations.list( + let ffiConversations = try await ffiConversations.list( opts: options) let sortedConversations = try await sortConversations( - conversations, order: order) - - return try sortedConversations.map { - try $0.toConversation(client: client) - } + ffiConversations, order: order) + + var conversations: [Conversation] = [] + for sortedConversation in sortedConversations { + let conversation = try await sortedConversation.toConversation(client: client) + conversations.append(conversation) + } + + return conversations } private func sortConversations( @@ -427,7 +431,7 @@ public actor Conversations { let conversation = try await ffiConversations .processStreamedWelcomeMessage(envelopeBytes: envelopeBytes) - return try conversation.toConversation(client: client) + return try await conversation.toConversation(client: client) } public func newConversation( diff --git a/Tests/XMTPTests/ConversationTests.swift b/Tests/XMTPTests/ConversationTests.swift index 2192e6c0..69c81326 100644 --- a/Tests/XMTPTests/ConversationTests.swift +++ b/Tests/XMTPTests/ConversationTests.swift @@ -16,9 +16,9 @@ class ConversationTests: XCTestCase { let dm = try await fixtures.boClient.conversations.findOrCreateDm( with: fixtures.caro.walletAddress) - let sameDm = try fixtures.boClient.findConversationByTopic( + let sameDm = try await fixtures.boClient.findConversationByTopic( topic: dm.topic) - let sameGroup = try fixtures.boClient.findConversationByTopic( + let sameGroup = try await fixtures.boClient.findConversationByTopic( topic: group.topic) XCTAssertEqual(group.id, sameGroup?.id) @@ -210,7 +210,7 @@ class ConversationTests: XCTestCase { XCTAssertEqual(try dm.consentState(), .denied) try await fixtures.boClient.conversations.sync() - let boDm = try fixtures.boClient.findConversation(conversationId: dm.id) + let boDm = try await fixtures.boClient.findConversation(conversationId: dm.id) var alixClient2 = try await Client.create( account: alix, @@ -232,7 +232,7 @@ class ConversationTests: XCTestCase { try await alixClient2.conversations.syncAllConversations() sleep(2) - if let dm2 = try alixClient2.findConversation(conversationId: dm.id) { + if let dm2 = try await alixClient2.findConversation(conversationId: dm.id) { XCTAssertEqual(try dm2.consentState(), .denied) try await alixClient2.preferences.setConsentState( diff --git a/Tests/XMTPTests/GroupPermissionsTests.swift b/Tests/XMTPTests/GroupPermissionsTests.swift index 43443c83..1b1ab180 100644 --- a/Tests/XMTPTests/GroupPermissionsTests.swift +++ b/Tests/XMTPTests/GroupPermissionsTests.swift @@ -39,7 +39,8 @@ class GroupPermissionTests: XCTestCase { try boGroup.isAdmin(inboxId: fixtures.boClient.inboxID)) XCTAssertTrue( try boGroup.isSuperAdmin(inboxId: fixtures.boClient.inboxID)) - XCTAssertFalse(try alixGroup.isCreator()) + let isAlixGroupCreator = try await alixGroup.isCreator() + XCTAssertFalse(isAlixGroupCreator) XCTAssertFalse( try alixGroup.isAdmin(inboxId: fixtures.alixClient.inboxID)) XCTAssertFalse( @@ -67,7 +68,8 @@ class GroupPermissionTests: XCTestCase { try boGroup.isAdmin(inboxId: fixtures.boClient.inboxID)) XCTAssertTrue( try boGroup.isSuperAdmin(inboxId: fixtures.boClient.inboxID)) - XCTAssertFalse(try alixGroup.isCreator()) + let isAlixGroupCreator = try await alixGroup.isCreator() + XCTAssertFalse(isAlixGroupCreator) XCTAssertFalse( try alixGroup.isAdmin(inboxId: fixtures.alixClient.inboxID)) XCTAssertFalse( diff --git a/Tests/XMTPTests/GroupTests.swift b/Tests/XMTPTests/GroupTests.swift index 6c43337b..cea21832 100644 --- a/Tests/XMTPTests/GroupTests.swift +++ b/Tests/XMTPTests/GroupTests.swift @@ -179,12 +179,12 @@ class GroupTests: XCTestCase { func testCanListGroupsFiltered() async throws { let fixtures = try await fixtures() - let dm = try await fixtures.boClient.conversations.findOrCreateDm( + let _ = try await fixtures.boClient.conversations.findOrCreateDm( with: fixtures.caro.walletAddress) let group = try await fixtures.boClient.conversations.newGroup(with: [ fixtures.caro.walletAddress ]) - let group2 = try await fixtures.boClient.conversations.newGroup(with: [ + let _ = try await fixtures.boClient.conversations.newGroup(with: [ fixtures.caro.walletAddress ]) @@ -230,9 +230,9 @@ class GroupTests: XCTestCase { XCTAssertEqual(conversationsOrdered.count, 2) XCTAssertEqual( - try conversations.map { try $0.id }, [group1.id, group2.id]) + conversations.map { $0.id }, [group1.id, group2.id]) XCTAssertEqual( - try conversationsOrdered.map { try $0.id }, + conversationsOrdered.map { $0.id }, [group2.id, group1.id]) }