Skip to content

Commit

Permalink
Merge pull request #539 from xmtp/ar/fix-conversation-params
Browse files Browse the repository at this point in the history
fix: Fix Conversations Params
  • Loading branch information
alexrisch authored Nov 19, 2024
2 parents 2192f53 + c9f5e83 commit a955447
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions ios/Wrappers/ConversationWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import XMTP

// Wrapper around XMTP.Conversation to allow passing these objects back into react native.
struct ConversationWrapper {
static func encodeToObj(_ conversation: XMTP.Conversation, client: XMTP.Client) async throws -> [String: Any] {
static func encodeToObj(_ conversation: XMTP.Conversation, client: XMTP.Client, conversationParams: ConversationParamsWrapper = ConversationParamsWrapper()) async throws -> [String: Any] {
switch conversation {
case .group(let group):
return try await GroupWrapper.encodeToObj(group, client: client)
return try await GroupWrapper.encodeToObj(group, client: client, conversationParams: conversationParams)
case .dm(let dm):
return try await DmWrapper.encodeToObj(dm, client: client)
return try await DmWrapper.encodeToObj(dm, client: client, conversationParams: conversationParams)
}
}

static func encode(_ conversation: XMTP.Conversation, client: XMTP.Client) async throws -> String {
let obj = try await encodeToObj(conversation, client: client)
static func encode(_ conversation: XMTP.Conversation, client: XMTP.Client, conversationParams: ConversationParamsWrapper = ConversationParamsWrapper()) async throws -> String {
let obj = try await encodeToObj(conversation, client: client, conversationParams: conversationParams)
let data = try JSONSerialization.data(withJSONObject: obj)
guard let result = String(data: data, encoding: .utf8) else {
throw WrapperError.encodeError("could not encode conversation")
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public class XMTPModule: Module {
for conversation in conversations {
let encodedConversationContainer =
try await ConversationWrapper.encode(
conversation, client: client)
conversation, client: client, conversationParams: params)
results.append(encodedConversationContainer)
}
return results
Expand Down

0 comments on commit a955447

Please sign in to comment.