Skip to content

Commit

Permalink
return number of active groups synced from sync all groups function. …
Browse files Browse the repository at this point in the history
…possible fork fixes (#393)

Co-authored-by: cameronvoell <cameronvoell@users.noreply.github.com>
  • Loading branch information
cameronvoell and cameronvoell authored Aug 26, 2024
1 parent 2e34f53 commit f40d43e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/xmtp/libxmtp-swift.git",
"state" : {
"revision" : "6ddc5a583663560698d66a7f99852ccb093cf4a5",
"version" : "0.5.7-beta2"
"revision" : "c27b586925714a253e5e9b3875788571552f46d6",
"version" : "0.5.8-beta1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
.package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"),
.package(url: "https://github.com/bufbuild/connect-swift", exact: "0.12.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
.package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "0.5.8-beta0"),
.package(url: "https://github.com/xmtp/libxmtp-swift.git", exact: "0.5.8-beta1"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
6 changes: 3 additions & 3 deletions Sources/XMTPiOS/Conversations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public actor Conversations {
try await v3Client.conversations().sync()
}

public func syncAllGroups() async throws {
public func syncAllGroups() async throws -> UInt32 {
guard let v3Client = client.v3Client else {
return
return 0
}
try await v3Client.conversations().syncAllGroups()
return try await v3Client.conversations().syncAllGroups()
}

public func groups(createdAfter: Date? = nil, createdBefore: Date? = nil, limit: Int? = nil) async throws -> [Group] {
Expand Down
19 changes: 18 additions & 1 deletion Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -853,17 +853,34 @@ class GroupTests: XCTestCase {
XCTAssertEqual(messageCount, 0)
do {
let start = Date()
let _ = try await fixtures.bobClient.conversations.syncAllGroups()
let numGroupsSynced = try await fixtures.bobClient.conversations.syncAllGroups()
let end = Date()
print(end.timeIntervalSince(start))
XCTAssert(end.timeIntervalSince(start) < 1)
XCTAssert(numGroupsSynced == 100)
} catch {
print("Failed to list groups members: \(error)")
throw error // Rethrow the error to fail the test if group creation fails
}

let messageCount2 = try await bobGroup!.messages().count
XCTAssertEqual(messageCount2, 1)

for aliceConv in try await fixtures.aliceClient.conversations.list(includeGroups: true) {
guard case let .group(aliceGroup) = aliceConv else {
XCTFail("failed converting conversation to group")
return
}
try await aliceGroup.removeMembers(addresses: [fixtures.bobClient.address])
}

// first syncAllGroups after removal still sync groups in order to process the removal
var numGroupsSynced = try await fixtures.bobClient.conversations.syncAllGroups()
XCTAssert(numGroupsSynced == 100)

// next syncAllGroups only will sync active groups
numGroupsSynced = try await fixtures.bobClient.conversations.syncAllGroups()
XCTAssert(numGroupsSynced == 0)
}

func testCanListManyMembersInParallelInUnderASecond() async throws {
Expand Down
4 changes: 2 additions & 2 deletions XMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "XMTP"
spec.version = "0.14.8"
spec.version = "0.14.9"
spec.summary = "XMTP SDK Cocoapod"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -44,5 +44,5 @@ Pod::Spec.new do |spec|
spec.dependency "web3.swift"
spec.dependency "GzipSwift"
spec.dependency "Connect-Swift", "= 0.12.0"
spec.dependency 'LibXMTP', '= 0.5.8-beta0'
spec.dependency 'LibXMTP', '= 0.5.8-beta1'
end

0 comments on commit f40d43e

Please sign in to comment.