Skip to content

Commit 157c889

Browse files
neekolasbennycodecameronvoell
authored
Upgrade to latest xmtp-ios/Android (#737)
* Add Zed editor config * Upgrade to 4.6.0-dev * Fix Android * Include all new fields * Dev release * Dev release * Remove Android build artifacts (#745) --------- Co-authored-by: Benny Neugebauer <[email protected]> Co-authored-by: cameronvoell <[email protected]>
1 parent 3788527 commit 157c889

34 files changed

+3454
-572
lines changed

.eslintrc.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module.exports = {
22
root: true,
3-
parser: "@typescript-eslint/parser",
3+
parser: '@typescript-eslint/parser',
44
parserOptions: {
5-
project: ["./tsconfig.json", "./example/tsconfig.json"]
6-
},
7-
plugins: ["@typescript-eslint"],
5+
project: ['./tsconfig.json', './example/tsconfig.json'],
6+
},
7+
plugins: ['@typescript-eslint'],
88
extends: ['universe/native', 'universe/web'],
99
ignorePatterns: ['build'],
1010
plugins: ['prettier'],
1111
globals: {
1212
__dirname: true,
1313
},
1414
rules: {
15-
"@typescript-eslint/no-floating-promises": ["error"],
15+
'@typescript-eslint/no-floating-promises': ['error'],
1616
},
1717
}

.zed/settings.json

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
// Formatter configuration
3+
"formatter": {
4+
"language_server": {
5+
"name": "typescript-language-server"
6+
}
7+
},
8+
9+
// Language-specific settings
10+
"languages": {
11+
"TypeScript": {
12+
"format_on_save": "on",
13+
"formatter": [
14+
{
15+
"code_action": "source.fixAll.eslint"
16+
},
17+
// {
18+
// "code_action": "source.organizeImports"
19+
// },
20+
{
21+
"external": {
22+
"command": "npx",
23+
"arguments": ["prettier", "--write", "--stdin-filepath", "{buffer_path}"]
24+
}
25+
}
26+
]
27+
},
28+
"JavaScript": {
29+
"format_on_save": "on",
30+
"formatter": [
31+
{
32+
"code_action": "source.fixAll.eslint"
33+
},
34+
// {
35+
// "code_action": "source.organizeImports"
36+
// },
37+
{
38+
"external": {
39+
"command": "npx",
40+
"arguments": ["prettier", "--write", "--stdin-filepath", "{buffer_path}"]
41+
}
42+
}
43+
]
44+
},
45+
"TSX": {
46+
"format_on_save": "on",
47+
"formatter": [
48+
{
49+
"code_action": "source.fixAll.eslint"
50+
},
51+
// {
52+
// "code_action": "source.organizeImports"
53+
// },
54+
{
55+
"external": {
56+
"command": "npx",
57+
"arguments": ["prettier", "--write", "--stdin-filepath", "{buffer_path}"]
58+
}
59+
}
60+
]
61+
},
62+
"Swift": {
63+
"format_on_save": "on",
64+
"tab_size": 2,
65+
"hard_tabs": false,
66+
"formatter": {
67+
"external": {
68+
"command": "swiftformat",
69+
"arguments": ["--quiet", "--stdinpath", "{buffer_path}"]
70+
}
71+
}
72+
},
73+
"Kotlin": {
74+
"format_on_save": "on",
75+
"tab_size": 2,
76+
"hard_tabs": false,
77+
"formatter": {
78+
"external": {
79+
"command": "ktlint",
80+
"arguments": [
81+
"-F",
82+
"--stdin",
83+
"--editorconfig=.editorconfig",
84+
"--log-level=none"
85+
]
86+
}
87+
}
88+
}
89+
},
90+
91+
// ESLint integration
92+
"lsp": {
93+
"eslint": {
94+
"settings": {
95+
"codeActionOnSave": {
96+
"enable": true,
97+
"mode": "all"
98+
},
99+
"format": false,
100+
"validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"]
101+
}
102+
}
103+
},
104+
105+
// File associations
106+
"file_types": {
107+
"TypeScript": ["ts"],
108+
"TSX": ["tsx"],
109+
"JavaScript": ["js", "cjs", "mjs"],
110+
"Swift": ["swift"],
111+
"Kotlin": ["kt", "kts"]
112+
},
113+
114+
// Project-specific settings
115+
"tab_size": 2,
116+
"hard_tabs": false,
117+
"remove_trailing_whitespace_on_save": true,
118+
"ensure_final_newline_on_save": true
119+
}

android/build.gradle

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,13 @@ afterEvaluate {
6868
android {
6969
compileSdkVersion safeExtGet("compileSdkVersion", 33)
7070

71-
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
72-
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
73-
compileOptions {
74-
sourceCompatibility JavaVersion.VERSION_11
75-
targetCompatibility JavaVersion.VERSION_11
76-
}
71+
compileOptions {
72+
sourceCompatibility JavaVersion.VERSION_17
73+
targetCompatibility JavaVersion.VERSION_17
74+
}
7775

78-
kotlinOptions {
79-
jvmTarget = JavaVersion.VERSION_11.majorVersion
80-
}
76+
kotlinOptions {
77+
jvmTarget = JavaVersion.VERSION_17.majorVersion
8178
}
8279

8380
defaultConfig {
@@ -98,7 +95,7 @@ repositories {
9895
dependencies {
9996
implementation project(':expo-modules-core')
10097
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
101-
implementation "org.xmtp:android:4.5.6"
98+
implementation "org.xmtp:android:4.6.0-dev.606cdda"
10299
implementation 'com.google.code.gson:gson:2.10.1'
103100
implementation 'com.facebook.react:react-native:0.71.3'
104101
implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1"

android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import expo.modules.xmtpreactnativesdk.wrappers.ClientWrapper
1818
import expo.modules.xmtpreactnativesdk.wrappers.ConsentWrapper
1919
import expo.modules.xmtpreactnativesdk.wrappers.ContentJson
2020
import expo.modules.xmtpreactnativesdk.wrappers.ConversationDebugInfoWrapper
21+
import expo.modules.xmtpreactnativesdk.wrappers.ConversationListParamsWrapper
2122
import expo.modules.xmtpreactnativesdk.wrappers.ConversationParamsWrapper
2223
import expo.modules.xmtpreactnativesdk.wrappers.ConversationWrapper
2324
import expo.modules.xmtpreactnativesdk.wrappers.CreateGroupParamsWrapper
@@ -30,6 +31,7 @@ import expo.modules.xmtpreactnativesdk.wrappers.InboxStateWrapper
3031
import expo.modules.xmtpreactnativesdk.wrappers.KeyPackageStatusWrapper
3132
import expo.modules.xmtpreactnativesdk.wrappers.MemberWrapper
3233
import expo.modules.xmtpreactnativesdk.wrappers.MembershipResultWrapper
34+
import expo.modules.xmtpreactnativesdk.wrappers.MessageQueryParamsWrapper
3335
import expo.modules.xmtpreactnativesdk.wrappers.MessageWrapper
3436
import expo.modules.xmtpreactnativesdk.wrappers.NetworkDebugInfoWrapper
3537
import expo.modules.xmtpreactnativesdk.wrappers.PermissionPolicySetWrapper
@@ -47,6 +49,7 @@ import org.xmtp.android.library.ClientOptions
4749
import org.xmtp.android.library.ConsentRecord
4850
import org.xmtp.android.library.ConsentState
4951
import org.xmtp.android.library.Conversation
52+
import org.xmtp.android.library.Conversations
5053
import org.xmtp.android.library.Conversations.ConversationFilterType
5154
import org.xmtp.android.library.PreEventCallback
5255
import org.xmtp.android.library.PreferenceType
@@ -71,6 +74,7 @@ import org.xmtp.android.library.libxmtp.GroupPermissionPreconfiguration
7174
import org.xmtp.android.library.libxmtp.PermissionOption
7275
import org.xmtp.android.library.libxmtp.PublicIdentity
7376
import org.xmtp.android.library.libxmtp.SignatureRequest
77+
import org.xmtp.android.library.MessageVisibilityOptions
7478
import org.xmtp.android.library.messages.PrivateKeyBuilder
7579
import org.xmtp.android.library.push.Service
7680
import org.xmtp.android.library.push.XMTPPush
@@ -901,47 +905,65 @@ class XMTPModule : Module() {
901905
).toJson()
902906
}
903907

904-
AsyncFunction("listGroups") Coroutine { installationId: String, groupParams: String?, limit: Int?, consentStringStates: List<String>? ->
908+
AsyncFunction("listGroups") Coroutine { installationId: String, groupParams: String?, queryParamsJson: String? ->
905909
withContext(Dispatchers.IO) {
906910
logV("listGroups")
907911
val client = clients[installationId] ?: throw XMTPException("No client")
908912
val params = ConversationParamsWrapper.conversationParamsFromJson(groupParams ?: "")
909-
val consentStates = consentStringStates?.let { ConsentWrapper.getConsentStates(it) }
913+
val queryParams = ConversationListParamsWrapper.conversationListParamsFromJson(queryParamsJson ?: "")
910914
val groups = client.conversations.listGroups(
911-
limit = limit,
912-
consentStates = consentStates
915+
createdAfterNs = queryParams.createdAfterNs,
916+
createdBeforeNs = queryParams.createdBeforeNs,
917+
lastActivityAfterNs = queryParams.lastActivityAfterNs,
918+
lastActivityBeforeNs = queryParams.lastActivityBeforeNs,
919+
limit = queryParams.limit,
920+
consentStates = queryParams.consentStates,
921+
orderBy = queryParams.orderBy ?: Conversations.ListConversationsOrderBy.LAST_ACTIVITY
913922
)
914923
groups.map { group ->
915924
GroupWrapper.encode(client, group, params)
916925
}
917926
}
918927
}
919928

920-
AsyncFunction("listDms") Coroutine { installationId: String, groupParams: String?, limit: Int?, consentStringStates: List<String>? ->
929+
AsyncFunction("listDms") Coroutine { installationId: String, groupParams: String?, queryParamsJson: String? ->
921930
withContext(Dispatchers.IO) {
922931
logV("listDms")
923932
val client = clients[installationId] ?: throw XMTPException("No client")
924933
val params = ConversationParamsWrapper.conversationParamsFromJson(groupParams ?: "")
925-
val consentStates = consentStringStates?.let { ConsentWrapper.getConsentStates(it) }
934+
val queryParams = ConversationListParamsWrapper.conversationListParamsFromJson(queryParamsJson ?: "")
926935
val dms = client.conversations.listDms(
927-
limit = limit,
928-
consentStates = consentStates
936+
createdAfterNs = queryParams.createdAfterNs,
937+
createdBeforeNs = queryParams.createdBeforeNs,
938+
lastActivityAfterNs = queryParams.lastActivityAfterNs,
939+
lastActivityBeforeNs = queryParams.lastActivityBeforeNs,
940+
limit = queryParams.limit,
941+
consentStates = queryParams.consentStates,
942+
orderBy = queryParams.orderBy ?: Conversations.ListConversationsOrderBy.LAST_ACTIVITY
929943
)
930944
dms.map { dm ->
931945
DmWrapper.encode(client, dm, params)
932946
}
933947
}
934948
}
935949

936-
AsyncFunction("listConversations") Coroutine { installationId: String, conversationParams: String?, limit: Int?, consentStringStates: List<String>? ->
950+
AsyncFunction("listConversations") Coroutine { installationId: String, conversationParams: String?, queryParamsJson: String? ->
937951
withContext(Dispatchers.IO) {
938952
logV("listConversations")
939953
val client = clients[installationId] ?: throw XMTPException("No client")
940954
val params =
941955
ConversationParamsWrapper.conversationParamsFromJson(conversationParams ?: "")
942-
val consentStates = consentStringStates?.let { ConsentWrapper.getConsentStates(it) }
956+
val queryParams = ConversationListParamsWrapper.conversationListParamsFromJson(queryParamsJson ?: "")
943957
val conversations =
944-
client.conversations.list(limit = limit, consentStates = consentStates)
958+
client.conversations.list(
959+
createdAfterNs = queryParams.createdAfterNs,
960+
createdBeforeNs = queryParams.createdBeforeNs,
961+
lastActivityAfterNs = queryParams.lastActivityAfterNs,
962+
lastActivityBeforeNs = queryParams.lastActivityBeforeNs,
963+
limit = queryParams.limit,
964+
consentStates = queryParams.consentStates,
965+
orderBy = queryParams.orderBy ?: Conversations.ListConversationsOrderBy.LAST_ACTIVITY
966+
)
945967
conversations.map { conversation ->
946968
ConversationWrapper.encode(client, conversation, params)
947969
}
@@ -966,33 +988,35 @@ class XMTPModule : Module() {
966988
}
967989
}
968990

969-
AsyncFunction("conversationMessages") Coroutine { installationId: String, conversationId: String, limit: Int?, beforeNs: Long?, afterNs: Long?, direction: String? ->
991+
AsyncFunction("conversationMessages") Coroutine { installationId: String, conversationId: String, queryParamsJson: String? ->
970992
withContext(Dispatchers.IO) {
971993
logV("conversationMessages")
972994
val client = clients[installationId] ?: throw XMTPException("No client")
973995
val conversation = client.conversations.findConversation(conversationId)
996+
val queryParams = MessageQueryParamsWrapper.messageQueryParamsFromJson(queryParamsJson ?: "")
974997
conversation?.messages(
975-
limit = limit,
976-
beforeNs = beforeNs,
977-
afterNs = afterNs,
998+
limit = queryParams.limit,
999+
beforeNs = queryParams.beforeNs,
1000+
afterNs = queryParams.afterNs,
9781001
direction = DecodedMessage.SortDirection.valueOf(
979-
direction ?: "DESCENDING"
1002+
queryParams.direction ?: "DESCENDING"
9801003
)
9811004
)?.map { MessageWrapper.encode(it) }
9821005
}
9831006
}
9841007

985-
AsyncFunction("conversationMessagesWithReactions") Coroutine { installationId: String, conversationId: String, limit: Int?, beforeNs: Long?, afterNs: Long?, direction: String? ->
1008+
AsyncFunction("conversationMessagesWithReactions") Coroutine { installationId: String, conversationId: String, queryParamsJson: String? ->
9861009
withContext(Dispatchers.IO) {
9871010
logV("conversationMessagesWithReactions")
9881011
val client = clients[installationId] ?: throw XMTPException("No client")
9891012
val conversation = client.conversations.findConversation(conversationId)
1013+
val queryParams = MessageQueryParamsWrapper.messageQueryParamsFromJson(queryParamsJson ?: "")
9901014
conversation?.messagesWithReactions(
991-
limit = limit,
992-
beforeNs = beforeNs,
993-
afterNs = afterNs,
1015+
limit = queryParams.limit,
1016+
beforeNs = queryParams.beforeNs,
1017+
afterNs = queryParams.afterNs,
9941018
direction = DecodedMessage.SortDirection.valueOf(
995-
direction ?: "DESCENDING"
1019+
queryParams.direction ?: "DESCENDING"
9961020
)
9971021
)?.map { MessageWrapper.encode(it) }
9981022
}
@@ -1065,7 +1089,7 @@ class XMTPModule : Module() {
10651089
}
10661090
}
10671091

1068-
AsyncFunction("sendEncodedContent") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int> ->
1092+
AsyncFunction("sendEncodedContent") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int>, shouldPush: Boolean ->
10691093
withContext(Dispatchers.IO) {
10701094
logV("sendEncodedContent")
10711095
val client = clients[installationId] ?: throw XMTPException("No client")
@@ -1081,7 +1105,7 @@ class XMTPModule : Module() {
10811105
}
10821106
}
10831107
val encodedContent = EncodedContent.parseFrom(encodedContentDataBytes)
1084-
conversation.send(encodedContent)
1108+
conversation.send(encodedContent, opts = MessageVisibilityOptions(shouldPush))
10851109
}
10861110
}
10871111

@@ -1123,7 +1147,7 @@ class XMTPModule : Module() {
11231147
}
11241148
}
11251149

1126-
AsyncFunction("prepareEncodedMessage") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int> ->
1150+
AsyncFunction("prepareEncodedMessage") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int>, shouldPush: Boolean ->
11271151
withContext(Dispatchers.IO) {
11281152
logV("prepareEncodedMessage")
11291153
val client = clients[installationId] ?: throw XMTPException("No client")
@@ -1139,7 +1163,7 @@ class XMTPModule : Module() {
11391163
}
11401164
}
11411165
val encodedContent = EncodedContent.parseFrom(encodedContentDataBytes)
1142-
conversation.prepareMessage(encodedContent = encodedContent)
1166+
conversation.prepareMessage(encodedContent = encodedContent, opts = MessageVisibilityOptions(shouldPush))
11431167
}
11441168
}
11451169

@@ -2318,5 +2342,3 @@ class XMTPModule : Module() {
23182342
}
23192343
}
23202344
}
2321-
2322-

0 commit comments

Comments
 (0)