Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return number of active groups synced from sync all groups function. possible fork fixes #393

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading