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

Fixed reaction preview #402

Merged
merged 1 commit into from
Nov 14, 2023
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
12 changes: 12 additions & 0 deletions src/controllers/MessagePreviewCardController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Loading