Skip to content
Open
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
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parser: '@typescript-eslint/parser',
parserOptions: {
project: ["./tsconfig.json", "./example/tsconfig.json"]
},
plugins: ["@typescript-eslint"],
project: ['./tsconfig.json', './example/tsconfig.json'],
},
plugins: ['@typescript-eslint'],
extends: ['universe/native', 'universe/web'],
ignorePatterns: ['build'],
plugins: ['prettier'],
globals: {
__dirname: true,
},
rules: {
"@typescript-eslint/no-floating-promises": ["error"],
'@typescript-eslint/no-floating-promises': ['error'],
},
}
119 changes: 119 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
// Formatter configuration
"formatter": {
"language_server": {
"name": "typescript-language-server"
}
},

// Language-specific settings
"languages": {
"TypeScript": {
"format_on_save": "on",
"formatter": [
{
"code_action": "source.fixAll.eslint"
},
// {
// "code_action": "source.organizeImports"
// },
{
"external": {
"command": "npx",
"arguments": ["prettier", "--write", "--stdin-filepath", "{buffer_path}"]
}
}
]
},
"JavaScript": {
"format_on_save": "on",
"formatter": [
{
"code_action": "source.fixAll.eslint"
},
// {
// "code_action": "source.organizeImports"
// },
{
"external": {
"command": "npx",
"arguments": ["prettier", "--write", "--stdin-filepath", "{buffer_path}"]
}
}
]
},
"TSX": {
"format_on_save": "on",
"formatter": [
{
"code_action": "source.fixAll.eslint"
},
// {
// "code_action": "source.organizeImports"
// },
{
"external": {
"command": "npx",
"arguments": ["prettier", "--write", "--stdin-filepath", "{buffer_path}"]
}
}
]
},
"Swift": {
"format_on_save": "on",
"tab_size": 2,
"hard_tabs": false,
"formatter": {
"external": {
"command": "swiftformat",
"arguments": ["--quiet", "--stdinpath", "{buffer_path}"]
}
}
},
"Kotlin": {
"format_on_save": "on",
"tab_size": 2,
"hard_tabs": false,
"formatter": {
"external": {
"command": "ktlint",
"arguments": [
"-F",
"--stdin",
"--editorconfig=.editorconfig",
"--log-level=none"
]
}
}
}
},

// ESLint integration
"lsp": {
"eslint": {
"settings": {
"codeActionOnSave": {
"enable": true,
"mode": "all"
},
"format": false,
"validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"]
}
}
},

// File associations
"file_types": {
"TypeScript": ["ts"],
"TSX": ["tsx"],
"JavaScript": ["js", "cjs", "mjs"],
"Swift": ["swift"],
"Kotlin": ["kt", "kts"]
},

// Project-specific settings
"tab_size": 2,
"hard_tabs": false,
"remove_trailing_whitespace_on_save": true,
"ensure_final_newline_on_save": true
}
17 changes: 7 additions & 10 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ afterEvaluate {
android {
compileSdkVersion safeExtGet("compileSdkVersion", 33)

def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.majorVersion
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.majorVersion
}

defaultConfig {
Expand All @@ -98,7 +95,7 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:4.5.6"
implementation "org.xmtp:android:4.6.0-dev.606cdda"
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import expo.modules.xmtpreactnativesdk.wrappers.ClientWrapper
import expo.modules.xmtpreactnativesdk.wrappers.ConsentWrapper
import expo.modules.xmtpreactnativesdk.wrappers.ContentJson
import expo.modules.xmtpreactnativesdk.wrappers.ConversationDebugInfoWrapper
import expo.modules.xmtpreactnativesdk.wrappers.ConversationListParamsWrapper
import expo.modules.xmtpreactnativesdk.wrappers.ConversationParamsWrapper
import expo.modules.xmtpreactnativesdk.wrappers.ConversationWrapper
import expo.modules.xmtpreactnativesdk.wrappers.CreateGroupParamsWrapper
Expand All @@ -30,6 +31,7 @@ import expo.modules.xmtpreactnativesdk.wrappers.InboxStateWrapper
import expo.modules.xmtpreactnativesdk.wrappers.KeyPackageStatusWrapper
import expo.modules.xmtpreactnativesdk.wrappers.MemberWrapper
import expo.modules.xmtpreactnativesdk.wrappers.MembershipResultWrapper
import expo.modules.xmtpreactnativesdk.wrappers.MessageQueryParamsWrapper
import expo.modules.xmtpreactnativesdk.wrappers.MessageWrapper
import expo.modules.xmtpreactnativesdk.wrappers.NetworkDebugInfoWrapper
import expo.modules.xmtpreactnativesdk.wrappers.PermissionPolicySetWrapper
Expand All @@ -47,6 +49,7 @@ import org.xmtp.android.library.ClientOptions
import org.xmtp.android.library.ConsentRecord
import org.xmtp.android.library.ConsentState
import org.xmtp.android.library.Conversation
import org.xmtp.android.library.Conversations
import org.xmtp.android.library.Conversations.ConversationFilterType
import org.xmtp.android.library.PreEventCallback
import org.xmtp.android.library.PreferenceType
Expand All @@ -71,6 +74,7 @@ import org.xmtp.android.library.libxmtp.GroupPermissionPreconfiguration
import org.xmtp.android.library.libxmtp.PermissionOption
import org.xmtp.android.library.libxmtp.PublicIdentity
import org.xmtp.android.library.libxmtp.SignatureRequest
import org.xmtp.android.library.MessageVisibilityOptions
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.push.Service
import org.xmtp.android.library.push.XMTPPush
Expand Down Expand Up @@ -901,47 +905,65 @@ class XMTPModule : Module() {
).toJson()
}

AsyncFunction("listGroups") Coroutine { installationId: String, groupParams: String?, limit: Int?, consentStringStates: List<String>? ->
AsyncFunction("listGroups") Coroutine { installationId: String, groupParams: String?, queryParamsJson: String? ->
withContext(Dispatchers.IO) {
logV("listGroups")
val client = clients[installationId] ?: throw XMTPException("No client")
val params = ConversationParamsWrapper.conversationParamsFromJson(groupParams ?: "")
val consentStates = consentStringStates?.let { ConsentWrapper.getConsentStates(it) }
val queryParams = ConversationListParamsWrapper.conversationListParamsFromJson(queryParamsJson ?: "")
val groups = client.conversations.listGroups(
limit = limit,
consentStates = consentStates
createdAfterNs = queryParams.createdAfterNs,
createdBeforeNs = queryParams.createdBeforeNs,
lastActivityAfterNs = queryParams.lastActivityAfterNs,
lastActivityBeforeNs = queryParams.lastActivityBeforeNs,
limit = queryParams.limit,
consentStates = queryParams.consentStates,
orderBy = queryParams.orderBy ?: Conversations.ListConversationsOrderBy.LAST_ACTIVITY
)
groups.map { group ->
GroupWrapper.encode(client, group, params)
}
}
}

AsyncFunction("listDms") Coroutine { installationId: String, groupParams: String?, limit: Int?, consentStringStates: List<String>? ->
AsyncFunction("listDms") Coroutine { installationId: String, groupParams: String?, queryParamsJson: String? ->
withContext(Dispatchers.IO) {
logV("listDms")
val client = clients[installationId] ?: throw XMTPException("No client")
val params = ConversationParamsWrapper.conversationParamsFromJson(groupParams ?: "")
val consentStates = consentStringStates?.let { ConsentWrapper.getConsentStates(it) }
val queryParams = ConversationListParamsWrapper.conversationListParamsFromJson(queryParamsJson ?: "")
val dms = client.conversations.listDms(
limit = limit,
consentStates = consentStates
createdAfterNs = queryParams.createdAfterNs,
createdBeforeNs = queryParams.createdBeforeNs,
lastActivityAfterNs = queryParams.lastActivityAfterNs,
lastActivityBeforeNs = queryParams.lastActivityBeforeNs,
limit = queryParams.limit,
consentStates = queryParams.consentStates,
orderBy = queryParams.orderBy ?: Conversations.ListConversationsOrderBy.LAST_ACTIVITY
)
dms.map { dm ->
DmWrapper.encode(client, dm, params)
}
}
}

AsyncFunction("listConversations") Coroutine { installationId: String, conversationParams: String?, limit: Int?, consentStringStates: List<String>? ->
AsyncFunction("listConversations") Coroutine { installationId: String, conversationParams: String?, queryParamsJson: String? ->
withContext(Dispatchers.IO) {
logV("listConversations")
val client = clients[installationId] ?: throw XMTPException("No client")
val params =
ConversationParamsWrapper.conversationParamsFromJson(conversationParams ?: "")
val consentStates = consentStringStates?.let { ConsentWrapper.getConsentStates(it) }
val queryParams = ConversationListParamsWrapper.conversationListParamsFromJson(queryParamsJson ?: "")
val conversations =
client.conversations.list(limit = limit, consentStates = consentStates)
client.conversations.list(
createdAfterNs = queryParams.createdAfterNs,
createdBeforeNs = queryParams.createdBeforeNs,
lastActivityAfterNs = queryParams.lastActivityAfterNs,
lastActivityBeforeNs = queryParams.lastActivityBeforeNs,
limit = queryParams.limit,
consentStates = queryParams.consentStates,
orderBy = queryParams.orderBy ?: Conversations.ListConversationsOrderBy.LAST_ACTIVITY
)
conversations.map { conversation ->
ConversationWrapper.encode(client, conversation, params)
}
Expand All @@ -966,33 +988,35 @@ class XMTPModule : Module() {
}
}

AsyncFunction("conversationMessages") Coroutine { installationId: String, conversationId: String, limit: Int?, beforeNs: Long?, afterNs: Long?, direction: String? ->
AsyncFunction("conversationMessages") Coroutine { installationId: String, conversationId: String, queryParamsJson: String? ->
withContext(Dispatchers.IO) {
logV("conversationMessages")
val client = clients[installationId] ?: throw XMTPException("No client")
val conversation = client.conversations.findConversation(conversationId)
val queryParams = MessageQueryParamsWrapper.messageQueryParamsFromJson(queryParamsJson ?: "")
conversation?.messages(
limit = limit,
beforeNs = beforeNs,
afterNs = afterNs,
limit = queryParams.limit,
beforeNs = queryParams.beforeNs,
afterNs = queryParams.afterNs,
direction = DecodedMessage.SortDirection.valueOf(
direction ?: "DESCENDING"
queryParams.direction ?: "DESCENDING"
)
)?.map { MessageWrapper.encode(it) }
}
}

AsyncFunction("conversationMessagesWithReactions") Coroutine { installationId: String, conversationId: String, limit: Int?, beforeNs: Long?, afterNs: Long?, direction: String? ->
AsyncFunction("conversationMessagesWithReactions") Coroutine { installationId: String, conversationId: String, queryParamsJson: String? ->
withContext(Dispatchers.IO) {
logV("conversationMessagesWithReactions")
val client = clients[installationId] ?: throw XMTPException("No client")
val conversation = client.conversations.findConversation(conversationId)
val queryParams = MessageQueryParamsWrapper.messageQueryParamsFromJson(queryParamsJson ?: "")
conversation?.messagesWithReactions(
limit = limit,
beforeNs = beforeNs,
afterNs = afterNs,
limit = queryParams.limit,
beforeNs = queryParams.beforeNs,
afterNs = queryParams.afterNs,
direction = DecodedMessage.SortDirection.valueOf(
direction ?: "DESCENDING"
queryParams.direction ?: "DESCENDING"
)
)?.map { MessageWrapper.encode(it) }
}
Expand Down Expand Up @@ -1065,7 +1089,7 @@ class XMTPModule : Module() {
}
}

AsyncFunction("sendEncodedContent") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int> ->
AsyncFunction("sendEncodedContent") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int>, shouldPush: Boolean ->
withContext(Dispatchers.IO) {
logV("sendEncodedContent")
val client = clients[installationId] ?: throw XMTPException("No client")
Expand All @@ -1081,7 +1105,7 @@ class XMTPModule : Module() {
}
}
val encodedContent = EncodedContent.parseFrom(encodedContentDataBytes)
conversation.send(encodedContent)
conversation.send(encodedContent, opts = MessageVisibilityOptions(shouldPush))
}
}

Expand Down Expand Up @@ -1123,7 +1147,7 @@ class XMTPModule : Module() {
}
}

AsyncFunction("prepareEncodedMessage") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int> ->
AsyncFunction("prepareEncodedMessage") Coroutine { installationId: String, conversationId: String, encodedContentData: List<Int>, shouldPush: Boolean ->
withContext(Dispatchers.IO) {
logV("prepareEncodedMessage")
val client = clients[installationId] ?: throw XMTPException("No client")
Expand All @@ -1139,7 +1163,7 @@ class XMTPModule : Module() {
}
}
val encodedContent = EncodedContent.parseFrom(encodedContentDataBytes)
conversation.prepareMessage(encodedContent = encodedContent)
conversation.prepareMessage(encodedContent = encodedContent, opts = MessageVisibilityOptions(shouldPush))
}
}

Expand Down Expand Up @@ -2318,5 +2342,3 @@ class XMTPModule : Module() {
}
}
}


Loading
Loading