Skip to content

Commit

Permalink
add missing async modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Dec 17, 2024
1 parent 90c88e8 commit 1b70951
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
18 changes: 11 additions & 7 deletions Sources/XMTPiOS/Conversations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions Tests/XMTPTests/ConversationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions Tests/XMTPTests/GroupPermissionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
])

Expand Down Expand Up @@ -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])
}

Expand Down

0 comments on commit 1b70951

Please sign in to comment.