From d24e2ac3bc6a707f074c9b27bbeeeddef68fad08 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Fri, 6 Jun 2025 06:55:32 +0200 Subject: [PATCH] Add type for Reaction --- src/components/Chat/ChatList.tsx | 11 ++++++++++- src/components/Chat/MessageItem.tsx | 11 ++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/Chat/ChatList.tsx b/src/components/Chat/ChatList.tsx index 305674c..3d8f84d 100644 --- a/src/components/Chat/ChatList.tsx +++ b/src/components/Chat/ChatList.tsx @@ -7,6 +7,15 @@ import { ChatOptions } from './ChatOptions'; import ErrorBoundary from '../../common/ErrorBoundary'; import { useTranslation } from 'react-i18next'; +type ReactionItem = { + sender: string; + senderName?: string; +}; + +export type ReactionsMap = { + [reactionType: string]: ReactionItem[]; +}; + export const ChatList = ({ initialMessages, myAddress, @@ -236,7 +245,7 @@ export const ChatList = ({ let message = messages[index] || null; // Safeguard against undefined let replyIndex = -1; let reply = null; - let reactions = null; + let reactions: ReactionsMap | null = null; let isUpdating = false; try { diff --git a/src/components/Chat/MessageItem.tsx b/src/components/Chat/MessageItem.tsx index c129408..4d412fd 100644 --- a/src/components/Chat/MessageItem.tsx +++ b/src/components/Chat/MessageItem.tsx @@ -53,6 +53,7 @@ import { messageHasImage, } from '../../utils/chat'; import { useTranslation } from 'react-i18next'; +import { ReactionsMap } from './ChatList'; const getBadgeImg = (level) => { switch (level?.toString()) { @@ -105,14 +106,14 @@ type MessageItemProps = { isShowingAsReply?: boolean; isTemp: boolean; isUpdating: boolean; - lastSignature: any; - message: any; - myAddress: any; + lastSignature: string; + message: string; + myAddress: string; onEdit: (messageId: string) => void; onReply: (messageId: string) => void; onSeen: () => void; - reactions: any; // could be null, or type it more strictly - reply: any; // same here + reactions: ReactionsMap | null; + reply: string | null; replyIndex: number; scrollToItem: (index: number) => void; };