diff --git a/Sources/XMTPiOS/Conversation.swift b/Sources/XMTPiOS/Conversation.swift index e2ba59cc..10db65b5 100644 --- a/Sources/XMTPiOS/Conversation.swift +++ b/Sources/XMTPiOS/Conversation.swift @@ -86,11 +86,7 @@ public enum Conversation: Sendable { case let .v2(conversationV2): return conversationV2.peerAddress case let .group(group): - var addresses = group.memberAddresses - if let index = addresses.firstIndex(of: clientAddress) { - addresses.remove(at: index) - } - return addresses.joined(separator: ",") + return group.peerAddresses.joined(separator: ",") } } @@ -101,11 +97,7 @@ public enum Conversation: Sendable { case let .v2(conversationV2): return [conversationV2.peerAddress] case let .group(group): - var addresses = group.memberAddresses - if let index = addresses.firstIndex(of: clientAddress) { - addresses.remove(at: index) - } - return addresses + return group.peerAddresses } } diff --git a/Sources/XMTPiOS/Group.swift b/Sources/XMTPiOS/Group.swift index 4ee5a601..d7789015 100644 --- a/Sources/XMTPiOS/Group.swift +++ b/Sources/XMTPiOS/Group.swift @@ -82,6 +82,14 @@ public struct Group: Identifiable, Equatable, Hashable { return [] } } + + public var peerAddresses: [String] { + var addresses = memberAddresses.map(\.localizedLowercase) + if let index = addresses.firstIndex(of: client.address.localizedLowercase) { + addresses.remove(at: index) + } + return addresses + } public var createdAt: Date { Date(millisecondsSinceEpoch: ffiGroup.createdAtNs()) diff --git a/Tests/XMTPTests/GroupTests.swift b/Tests/XMTPTests/GroupTests.swift index b7006464..7d916186 100644 --- a/Tests/XMTPTests/GroupTests.swift +++ b/Tests/XMTPTests/GroupTests.swift @@ -190,8 +190,11 @@ class GroupTests: XCTestCase { try await group.sync() let members = group.memberAddresses.map(\.localizedLowercase).sorted() + let peerMembers = Conversation.group(group).peerAddresses.map(\.localizedLowercase).sorted() + XCTAssertEqual([fixtures.bob.address.localizedLowercase, fixtures.alice.address.localizedLowercase].sorted(), members) + XCTAssertEqual([fixtures.bob.address.localizedLowercase].sorted(), peerMembers) } func testCanAddGroupMembers() async throws { diff --git a/XMTP.podspec b/XMTP.podspec index 415352db..a6bff3aa 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "XMTP" - spec.version = "0.8.12" + spec.version = "0.8.13" spec.summary = "XMTP SDK Cocoapod" # This description is used to generate tags and improve search results.