From c9f5e8307937c738212fe3c11f7a749bf7fc9c90 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Mon, 18 Nov 2024 19:45:09 -0500 Subject: [PATCH] fix: Fix Conversations Params Pass Conversation Params to conversation wrapper --- ios/Wrappers/ConversationWrapper.swift | 11 +++++------ ios/XMTPModule.swift | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ios/Wrappers/ConversationWrapper.swift b/ios/Wrappers/ConversationWrapper.swift index c4e3af3e5..0900c1cf8 100644 --- a/ios/Wrappers/ConversationWrapper.swift +++ b/ios/Wrappers/ConversationWrapper.swift @@ -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") diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index fdcfa1f96..ffa477516 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -470,7 +470,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