From c944481a1ff129a173d8395557aab4eb31b65e9d Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 2 Nov 2023 13:24:16 -0700 Subject: [PATCH] feat: add fallback types to content types --- .../xmtpreactnativesdk/wrappers/DecodedMessageWrapper.kt | 1 + example/src/tests.ts | 8 ++++++++ ios/Wrappers/DecodedMessageWrapper.swift | 1 + src/XMTP.types.ts | 1 + 4 files changed, 11 insertions(+) diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/DecodedMessageWrapper.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/DecodedMessageWrapper.kt index f8471d28c..a0f7a3126 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/DecodedMessageWrapper.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/DecodedMessageWrapper.kt @@ -21,6 +21,7 @@ class DecodedMessageWrapper { "content" to ContentJson(model.encodedContent).toJsonMap(), "senderAddress" to model.senderAddress, "sent" to model.sent.time, + "fallback" to model.fallbackContent ) } } diff --git a/example/src/tests.ts b/example/src/tests.ts index 78c8c40c2..5ce075b5f 100644 --- a/example/src/tests.ts +++ b/example/src/tests.ts @@ -168,6 +168,10 @@ test("can list batch messages", async () => { throw Error("Unexpected message content " + messages[0].content); } + if (messages[0].fallback !== 'Reacted “💖” to an earlier message') { + throw Error("Unexpected message fallback " + messages[0].fallback); + } + return true; }); @@ -488,6 +492,10 @@ test("can send read receipts", async () => { throw Error("Unexpected message content " + bobMessages[0].content); } + if (bobMessages[0].fallback) { + throw Error("Unexpected message fallback " + bobMessages[0].fallback); + } + return true; }); diff --git a/ios/Wrappers/DecodedMessageWrapper.swift b/ios/Wrappers/DecodedMessageWrapper.swift index 41e26429c..a8226b593 100644 --- a/ios/Wrappers/DecodedMessageWrapper.swift +++ b/ios/Wrappers/DecodedMessageWrapper.swift @@ -12,6 +12,7 @@ struct DecodedMessageWrapper { "content": ContentJson.fromEncoded(model.encodedContent, client: model.client).toJsonMap() as Any, "senderAddress": model.senderAddress, "sent": UInt64(model.sent.timeIntervalSince1970 * 1000), + "fallback": model.fallbackContent ] } diff --git a/src/XMTP.types.ts b/src/XMTP.types.ts index 540e4e325..967e3d975 100644 --- a/src/XMTP.types.ts +++ b/src/XMTP.types.ts @@ -96,6 +96,7 @@ export type DecodedMessage = { content: MessageContent; senderAddress: string; sent: number; // timestamp in milliseconds + fallback: string | undefined; }; export type ConversationContext = {