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

Fix Forked Group State #421

Merged
merged 5 commits into from
Jun 17, 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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:0.13.5"
implementation "org.xmtp:android:0.13.6"
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.facebook.react:react-native:0.71.3'
implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1"
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ PODS:
- hermes-engine/Pre-built (= 0.71.14)
- hermes-engine/Pre-built (0.71.14)
- libevent (2.1.12)
- LibXMTP (0.5.1-beta2)
- LibXMTP (0.5.2-beta0)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.5):
Expand Down Expand Up @@ -449,16 +449,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.12.0):
- XMTP (0.12.1):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.5.1-beta2)
- LibXMTP (= 0.5.2-beta0)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.12.0)
- XMTP (= 0.12.1)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,7 +711,7 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: 954acfb393be3b19bf44ea9009af558c00222450
LibXMTP: b56bf1afe38e21e967d6b3c8d840a41164ffdb64
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb
Expand Down Expand Up @@ -763,8 +763,8 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: 3d34d8922840d75b8d281ed989843ee813000582
XMTPReactNative: 4d103fca76e388aebf1cb829e37f4a8e36193e58
XMTP: 5e28d39dd43b9f8b85861b09cce47efce1da2d8e
XMTPReactNative: 47e3bcf71f97ea840aa07af3220245ccb7626ef4
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2
Expand Down
75 changes: 75 additions & 0 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,81 @@
return true
})

test('can list groups does not fork', async () => {
const [alix, bo] = await createClients(2)
console.log('created clients')
let groupCallbacks = 0
//#region Stream groups
await bo.conversations.streamGroups(async () => {
console.log('group received')
groupCallbacks++
})
//#region Stream All Messages
await bo.conversations.streamAllMessages(async () => {
console.log('message received')
}, true)
//#endregion
// #region create group
const alixGroup = await alix.conversations.newGroup([bo.address])
await alixGroup.updateGroupName('hello')
await alixGroup.send('hello1')
console.log('sent group message')
// #endregion
// #region sync groups
await bo.conversations.syncGroups()
// #endregion
const boGroups = await bo.conversations.listGroups()
assert(boGroups.length === 1, 'bo should have 1 group')
const boGroup = boGroups[0]
await boGroup.sync()

const boMessages1 = await boGroup.messages()
assert(
boMessages1.length === 2,
`should have 2 messages on first load received ${boMessages1.length}`
)
await boGroup.send('hello2')
await boGroup.send('hello3')
await alixGroup.sync()
const alixMessages = await alixGroup.messages()
for (const message of alixMessages) {
console.log(
'message',
message.contentTypeId,
message.contentTypeId === 'xmtp.org/text:1.0'
? message.content()
: 'Group Updated'
)
}
// alix sees 3 messages
assert(
alixMessages.length === 5,
`should have 5 messages on first load received ${alixMessages.length}`
)
await alixGroup.send('hello4')
await boGroup.sync()
const boMessages2 = await boGroup.messages()
for (const message of boMessages2) {
console.log(
'message',
message.contentTypeId,
message.contentTypeId === 'xmtp.org/text:1.0'
? message.content()
: 'Group Updated'
)
}
// bo sees 4 messages
assert(
boMessages2.length === 5,
`should have 5 messages on second load received ${boMessages2.length}`
)

assert(groupCallbacks === 1, 'group stream should have received 1 group')

return true
})


Check warning on line 1734 in example/src/tests/groupTests.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`
// Commenting this out so it doesn't block people, but nice to have?
// test('can stream messages for a long time', async () => {
// const bo = await Client.createRandom({ env: 'local', enableV3: true })
Expand Down
4 changes: 1 addition & 3 deletions example/src/tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export function assert(condition: boolean, msg: string) {
}
}

export async function createClients(
numClients: number
): Promise<Client<any>[]> {
export async function createClients(numClients: number): Promise<Client[]> {
const clients = []
for (let i = 0; i < numClients; i++) {
const keyBytes = new Uint8Array([
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Pod::Spec.new do |s|
s.source_files = "**/*.{h,m,swift}"
s.dependency 'secp256k1.swift'
s.dependency "MessagePacker"
s.dependency "XMTP", "= 0.12.0"
s.dependency "XMTP", "= 0.12.1"
end
Loading