@@ -91,22 +91,16 @@ class Client() {
91
91
codecRegistry.register(codec = codec)
92
92
}
93
93
94
- suspend fun <T > withFfiClient (
95
- appContext : Context ,
94
+ private suspend fun <T > withFfiClient (
96
95
api : ClientOptions .Api ,
97
96
useClient : suspend (ffiClient: FfiXmtpClient ) -> T ,
98
97
): T {
99
98
val accountAddress = " 0x0000000000000000000000000000000000000000"
100
99
val inboxId = getOrCreateInboxId(api, accountAddress)
101
- val alias = " xmtp-${api.env} -$inboxId "
102
-
103
- val directoryFile = File (appContext.filesDir.absolutePath, " xmtp_db" )
104
- directoryFile.mkdir()
105
- val dbPath = directoryFile.absolutePath + " /$alias .db3"
106
100
107
101
val ffiClient = createClient(
108
102
api = connectToApiBackend(api),
109
- db = dbPath ,
103
+ db = null ,
110
104
encryptionKey = null ,
111
105
accountAddress = accountAddress.lowercase(),
112
106
inboxId = inboxId,
@@ -115,30 +109,23 @@ class Client() {
115
109
historySyncUrl = null
116
110
)
117
111
118
- return try {
119
- useClient(ffiClient)
120
- } finally {
121
- ffiClient.releaseDbConnection()
122
- File (dbPath).delete()
123
- }
112
+ return useClient(ffiClient)
124
113
}
125
114
126
115
suspend fun inboxStatesForInboxIds (
127
116
inboxIds : List <String >,
128
- appContext : Context ,
129
117
api : ClientOptions .Api ,
130
118
): List <InboxState > {
131
- return withFfiClient(appContext, api) { ffiClient ->
119
+ return withFfiClient(api) { ffiClient ->
132
120
ffiClient.addressesFromInboxId(true , inboxIds).map { InboxState (it) }
133
121
}
134
122
}
135
123
136
124
suspend fun canMessage (
137
125
accountAddresses : List <String >,
138
- appContext : Context ,
139
126
api : ClientOptions .Api ,
140
127
): Map <String , Boolean > {
141
- return withFfiClient(appContext, api) { ffiClient ->
128
+ return withFfiClient(api) { ffiClient ->
142
129
ffiClient.canMessage(accountAddresses)
143
130
}
144
131
}
@@ -332,7 +319,7 @@ class Client() {
332
319
333
320
fun findGroup (groupId : String ): Group ? {
334
321
return try {
335
- Group (this , ffiClient.conversation(groupId.hexToByteArray()))
322
+ Group (this .inboxId , ffiClient.conversation(groupId.hexToByteArray()))
336
323
} catch (e: Exception ) {
337
324
null
338
325
}
@@ -342,8 +329,8 @@ class Client() {
342
329
return try {
343
330
val conversation = ffiClient.conversation(conversationId.hexToByteArray())
344
331
when (conversation.conversationType()) {
345
- FfiConversationType .GROUP -> Conversation .Group (Group (this , conversation))
346
- FfiConversationType .DM -> Conversation .Dm (Dm (this , conversation))
332
+ FfiConversationType .GROUP -> Conversation .Group (Group (this .inboxId , conversation))
333
+ FfiConversationType .DM -> Conversation .Dm (Dm (this .inboxId , conversation))
347
334
else -> null
348
335
}
349
336
} catch (e: Exception ) {
@@ -358,8 +345,8 @@ class Client() {
358
345
return try {
359
346
val conversation = ffiClient.conversation(conversationId.hexToByteArray())
360
347
when (conversation.conversationType()) {
361
- FfiConversationType .GROUP -> Conversation .Group (Group (this , conversation))
362
- FfiConversationType .DM -> Conversation .Dm (Dm (this , conversation))
348
+ FfiConversationType .GROUP -> Conversation .Group (Group (this .inboxId , conversation))
349
+ FfiConversationType .DM -> Conversation .Dm (Dm (this .inboxId , conversation))
363
350
else -> null
364
351
}
365
352
} catch (e: Exception ) {
@@ -369,7 +356,7 @@ class Client() {
369
356
370
357
fun findDmByInboxId (inboxId : String ): Dm ? {
371
358
return try {
372
- Dm (this , ffiClient.dmConversation(inboxId))
359
+ Dm (this .inboxId , ffiClient.dmConversation(inboxId))
373
360
} catch (e: Exception ) {
374
361
null
375
362
}
0 commit comments