Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix Conversations Params #539

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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
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 @@ -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
Expand Down
Loading