Skip to content

Commit

Permalink
Fix example app (needed to add manual syncs)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakajima committed Feb 5, 2024
1 parent 534a67f commit 8086b78
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
18 changes: 15 additions & 3 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,29 @@ class GroupTests: XCTestCase {
let alice = try PrivateKey.generate()
let aliceClient = try await Client.create(
account: alice,
options: .init(api: .init(env: .local, isSecure: false), codecs: [GroupMembershipChangedCodec()], enableAlphaMLS: true)
options: .init(
api: .init(env: .local, isSecure: false),
codecs: [GroupMembershipChangedCodec()],
mlsAlpha: true
)
)
let bob = try PrivateKey.generate()
let bobClient = try await Client.create(
account: bob,
options: .init(api: .init(env: .local, isSecure: false), codecs: [GroupMembershipChangedCodec()], enableAlphaMLS: true)
options: .init(
api: .init(env: .local, isSecure: false),
codecs: [GroupMembershipChangedCodec()],
mlsAlpha: true
)
)
let fred = try PrivateKey.generate()
let fredClient = try await Client.create(
account: fred,
options: .init(api: .init(env: .local, isSecure: false), codecs: [GroupMembershipChangedCodec()], enableAlphaMLS: true)
options: .init(
api: .init(env: .local, isSecure: false),
codecs: [GroupMembershipChangedCodec()],
mlsAlpha: true
)
)

return .init(
Expand Down
4 changes: 2 additions & 2 deletions XMTPiOSExample/XMTPiOSExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct ContentView: View {
options: .init(
api: .init(env: .local, isSecure: false),
codecs: [GroupMembershipChangedCodec()],
enableAlphaMLS: true
mlsAlpha: true
)
)
await MainActor.run {
Expand Down Expand Up @@ -97,7 +97,7 @@ struct ContentView: View {
options: .init(
api: .init(env: .local, isSecure: false, appVersion: "XMTPTest/v1.0.0"),
codecs: [GroupMembershipChangedCodec()],
enableAlphaMLS: true
mlsAlpha: true
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct ConversationListView: View {
ConversationOrGroup.conversation($0)
}

try await client.conversations.sync()

let groups = try await client.conversations.groups().map {
ConversationOrGroup.group($0)
}
Expand Down
1 change: 1 addition & 0 deletions XMTPiOSExample/XMTPiOSExample/Views/GroupDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct GroupDetailView: View {

func loadMessages() async {
do {
try await group.sync()
let messages = try await group.messages()
await MainActor.run {
self.messages = messages
Expand Down
2 changes: 1 addition & 1 deletion XMTPiOSExample/XMTPiOSExample/Views/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ struct LoginView: View {
options: .init(
api: .init(env: .local, isSecure: false),
codecs: [GroupMembershipChangedCodec()],
enableAlphaMLS: true
mlsAlpha: true
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum ConversationOrGroup: Identifiable, Hashable {
case .conversation(let conversation):
return conversation.peerAddress
case .group(let group):
return group.members.map(\.accountAddress).joined(separator: ",")
return group.members.joined(separator: ",")
}
}
}
Expand Down Expand Up @@ -111,6 +111,7 @@ struct NewConversationView: View {
Task {
do {
let group = try await client.conversations.newGroup(with: groupMembers)
try await client.conversations.sync()
await MainActor.run {
onCreate(.group(group))
}
Expand Down

0 comments on commit 8086b78

Please sign in to comment.