From 41f216cd2d0f0d13fa007fe243f7d1af7795ab31 Mon Sep 17 00:00:00 2001 From: daria-github Date: Tue, 14 Nov 2023 09:39:09 -0800 Subject: [PATCH] fixed reaction preview --- src/controllers/MessagePreviewCardController.tsx | 12 ++++++++++++ src/locales/en_US.json | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/controllers/MessagePreviewCardController.tsx b/src/controllers/MessagePreviewCardController.tsx index ecde9864..488680d6 100644 --- a/src/controllers/MessagePreviewCardController.tsx +++ b/src/controllers/MessagePreviewCardController.tsx @@ -12,6 +12,8 @@ import { ContentTypeAttachment, ContentTypeRemoteAttachment, } from "@xmtp/content-type-remote-attachment"; +import type { Reaction } from "@xmtp/content-type-reaction"; +import { ContentTypeReaction } from "@xmtp/content-type-reaction"; import { MessagePreviewCard } from "../component-library/components/MessagePreviewCard/MessagePreviewCard"; import type { ETHAddress } from "../helpers"; import { shortAddress } from "../helpers"; @@ -95,6 +97,16 @@ export const MessagePreviewCardController = ({ previewContentType = reply.contentType; } + if (ContentTypeReaction.sameAs(previewContentType)) { + return (previewContent as Reaction).action === "removed" + ? t("messages.unreaction_preview", { + REACTION: (previewContent as Reaction).content, + }) + : t("messages.reaction_preview", { + REACTION: (previewContent as Reaction).content, + }); + } + if (ContentTypeText.sameAs(previewContentType)) { return (previewContent as string) ?? lastMessage.contentFallback; } diff --git a/src/locales/en_US.json b/src/locales/en_US.json index b216b8af..9ba06c02 100644 --- a/src/locales/en_US.json +++ b/src/locales/en_US.json @@ -47,6 +47,8 @@ "message_retry": "Retry", "message_cancel": "Cancel", "no_preview": "No preview available", + "reaction_preview": "Reacted with {{REACTION}} to earlier message", + "unreaction_preview": "Unreacted with {{REACTION}} to earlier message", "reply": "Reply", "view_replies": "View replies" },